Skip to content

Commit

Permalink
[dev.go2go] go/types: fix instantiation crash for generic type parame…
Browse files Browse the repository at this point in the history
…ters

Fixes #40038.
  • Loading branch information
tdakkota committed Aug 11, 2020
1 parent ead7e9b commit 3e5067a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/go/types/fixedbugs/issue40038.go2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package p

type A[type T] int

func (A[T]) m(A[T])

func f[type P interface{m(P)}]()

func _() {
_ = f[A]
}
2 changes: 1 addition & 1 deletion src/go/types/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
// In order to compare the signatures, substitute the receiver
// type parameters of ftyp with V's instantiation type arguments.
// This lazily instantiates the signature of method f.
if Vn != nil && len(Vn.targs) > 0 {
if Vn != nil && len(Vn.tparams) > 0 {
// Be careful: The number of type arguments may not match
// the number of receiver parameters. If so, an error was
// reported earlier but the length discrepancy is still
Expand Down

0 comments on commit 3e5067a

Please sign in to comment.