From cb2cbbcda28e01738dde5a00bbd3487c6cbdf948 Mon Sep 17 00:00:00 2001 From: tdakkota Date: Tue, 11 Aug 2020 07:56:31 +0000 Subject: [PATCH] =?UTF-8?q?[dev.go2go]=20go/types:=20fix=20instantiation?= =?UTF-8?q?=20crash=20for=20generic=20type=20parame=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …ters Fixes #40038. Change-Id: I5b095d01fd1e3703561c179c34ddc3b43d7510f6 GitHub-Last-Rev: 3e5067a780cdec9143ad32bc5bb8954496a4d5f6 GitHub-Pull-Request: golang/go#40644 Reviewed-on: https://go-review.googlesource.com/c/go/+/247498 Run-TryBot: Robert Griesemer TryBot-Result: Gobot Gobot Reviewed-by: Robert Griesemer --- src/go/types/fixedbugs/issue40038.go2 | 15 +++++++++++++++ src/go/types/lookup.go | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/go/types/fixedbugs/issue40038.go2 diff --git a/src/go/types/fixedbugs/issue40038.go2 b/src/go/types/fixedbugs/issue40038.go2 new file mode 100644 index 0000000000..731018712d --- /dev/null +++ b/src/go/types/fixedbugs/issue40038.go2 @@ -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] +} \ No newline at end of file diff --git a/src/go/types/lookup.go b/src/go/types/lookup.go index 3b91da025c..d6740945d4 100644 --- a/src/go/types/lookup.go +++ b/src/go/types/lookup.go @@ -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