// over any pointer)
recvType := nameNode.Type().Recv().Type
recvType = deref(recvType)
+ if recvType.IsFullyInstantiated() {
+ // Get the type of the base generic type, so we get
+ // its original typeparams.
+ recvType = recvType.OrigSym().Def.(*ir.Name).Type()
+ }
tparams = recvType.RParams()
} else {
fields := nameNode.Type().TParams().Fields().Slice()
s1 := make([]*types.Type, len(shapes))
for i, t := range shapes {
var tparam *types.Type
- if tparams[i].Kind() == types.TTYPEPARAM {
- // Shapes are grouped differently for structural types, so we
- // pass the type param to Shapify(), so we can distinguish.
- tparam = tparams[i]
- }
+ // Shapes are grouped differently for structural types, so we
+ // pass the type param to Shapify(), so we can distinguish.
+ tparam = tparams[i]
if !t.IsShape() {
s1[i] = typecheck.Shapify(t, i, tparam)
} else {
// For now, we only consider two types to have the same shape, if they have exactly
// the same underlying type or they are both pointer types.
//
-// tparam is the associated typeparam. If there is a structural type for
-// the associated type param (not common), then a pointer type t is mapped to its
-// underlying type, rather than being merged with other pointers.
+// tparam is the associated typeparam - it must be TTYPEPARAM type. If there is a
+// structural type for the associated type param (not common), then a pointer type t
+// is mapped to its underlying type, rather than being merged with other pointers.
//
// Shape types are also distinguished by the index of the type in a type param/arg
// list. We need to do this so we can distinguish and substitute properly for two
--- /dev/null
+// Copyright 2022 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 a
+
+type A[T any] struct{}
+
+func (_ A[T]) Method() {}
+
+func DoSomething[P any]() {
+ a := A[*byte]{}
+ a.Method()
+}
--- /dev/null
+// Copyright 2022 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 main
+
+import (
+ "a"
+)
+
+func main() {
+ a.DoSomething[byte]()
+}
--- /dev/null
+// rundir -G=3
+
+// Copyright 2022 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 ignored