aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/reader.go
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2024-01-31 14:47:40 +0700
committerGopher Robot <gobot@golang.org>2024-07-16 16:43:30 +0000
commit8b48290895d362417124bcc18f0e6b6476ddc99e (patch)
tree0d87fb70b188b5727949b388aea173ccfe66281f /src/cmd/compile/internal/noder/reader.go
parent959b3fd4265d7e4efb18af454cd18799ed70b8fe (diff)
downloadgo-8b48290895d362417124bcc18f0e6b6476ddc99e.tar.xz
cmd/compile: fix recursive generic interface instantiation
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>
Diffstat (limited to 'src/cmd/compile/internal/noder/reader.go')
-rw-r--r--src/cmd/compile/internal/noder/reader.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go
index 97865bbfb1..58fbb72f5d 100644
--- a/src/cmd/compile/internal/noder/reader.go
+++ b/src/cmd/compile/internal/noder/reader.go
@@ -903,6 +903,11 @@ func shapify(targ *types.Type, basic bool) *types.Type {
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