mirror of
https://github.com/golang/go
synced 2024-11-11 12:49:30 +00:00
8b48290895
When shapifying recursive instantiated types, the compiler ends up leaving the type as-is if it already has been a shape type. However, if both of type arguments are interfaces, and one of them is a recursive one, it ends up being shaped as-is, while the other is shaped to its underlying, causing mismatch in function signature. Fixing this by shapifying an interface type as-is, if it is fully instantiated and already been a shape type. Fixes #65362 Fixes #66663 Change-Id: I839d266e0443b41238b1b7362aca09adc0177362 Reviewed-on: https://go-review.googlesource.com/c/go/+/559656 Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
35 lines
601 B
Go
35 lines
601 B
Go
// 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]()
|