Skip to content

Commit cb2cbbc

Browse files
tdakkotagriesemer
authored andcommitted
[dev.go2go] go/types: fix instantiation crash for generic type parame…
…ters Fixes #40038. Change-Id: I5b095d01fd1e3703561c179c34ddc3b43d7510f6 GitHub-Last-Rev: 3e5067a GitHub-Pull-Request: #40644 Reviewed-on: https://go-review.googlesource.com/c/go/+/247498 Run-TryBot: Robert Griesemer <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 6d33075 commit cb2cbbc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/go/types/fixedbugs/issue40038.go2

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2020 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package p
6+
7+
type A[type T] int
8+
9+
func (A[T]) m(A[T])
10+
11+
func f[type P interface{m(P)}]()
12+
13+
func _() {
14+
_ = f[A]
15+
}

src/go/types/lookup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
396396
// In order to compare the signatures, substitute the receiver
397397
// type parameters of ftyp with V's instantiation type arguments.
398398
// This lazily instantiates the signature of method f.
399-
if Vn != nil && len(Vn.targs) > 0 {
399+
if Vn != nil && len(Vn.tparams) > 0 {
400400
// Be careful: The number of type arguments may not match
401401
// the number of receiver parameters. If so, an error was
402402
// reported earlier but the length discrepancy is still

0 commit comments

Comments
 (0)