[dev.go2go] go/types: fix instantiation crash for generic type parameters

Fixes #40038.
This commit is contained in:
tdakkota 2020-08-11 10:42:04 +03:00
parent ead7e9b351
commit 3e5067a780
2 changed files with 16 additions and 1 deletions

View File

@ -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]
}

View File

@ -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