base.Fatalf("%v is missing its underlying type", targ)
}
}
+ // For fully instantiated shape interface type, use it as-is. Otherwise, the instantiation
+ // involved recursive generic interface may cause mismatching in function signature, see issue #65362.
+ if targ.Kind() == types.TINTER && targ.IsFullyInstantiated() && targ.HasShape() {
+ return targ
+ }
// When a pointer type is used to instantiate a type parameter
// constrained by a basic interface, we know the pointer's element
--- /dev/null
+// compile
+
+// Copyright 2024 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
+
+type Vector[V any] interface {
+ ReadVector[V]
+}
+
+type ReadVector[V any] interface {
+ Comparisons[ReadVector[V], Vector[V]]
+}
+
+type Comparisons[RV, V any] interface {
+ Diff(RV) V
+}
+
+type VectorImpl[V any] struct{}
+
+func (*VectorImpl[V]) Diff(ReadVector[V]) (_ Vector[V]) {
+ return
+}
+
+func main() {
+ var v1 VectorImpl[int]
+ var v2 Vector[int]
+ _ = v1.Diff(v2)
+}
--- /dev/null
+// compile
+
+// Copyright 2024 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 Iterator[A any] func() (bool, A)
+
+type Range[A any] interface {
+ Blocks() Iterator[Block[A]]
+}
+
+type Block[A any] interface {
+ Range[A]
+}
+
+type rangeImpl[A any] struct{}
+
+func (r *rangeImpl[A]) Blocks() Iterator[Block[A]] {
+ return func() (bool, Block[A]) {
+ var a Block[A]
+ return false, a
+ }
+}
+
+func NewRange[A any]() Range[A] {
+ return &rangeImpl[A]{}
+}
+
+type AddrImpl struct{}
+
+var _ = NewRange[AddrImpl]()