From: Mateusz Poliwczak Date: Sun, 12 Oct 2025 09:15:11 +0000 (+0200) Subject: cmd/compile/internal/devirtualize: fix OCONVNOP assertion X-Git-Tag: go1.26rc1~626 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5a9ef44bc0;p=gostls13.git cmd/compile/internal/devirtualize: fix OCONVNOP assertion Fixes #75863 Change-Id: I1e5a0f3880dcd5f820a5b6f4540c49b16a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/711141 Reviewed-by: Keith Randall Reviewed-by: Lasse Folger Auto-Submit: Keith Randall Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/compile/internal/devirtualize/devirtualize.go b/src/cmd/compile/internal/devirtualize/devirtualize.go index 9d4160085e..363cd6f2e5 100644 --- a/src/cmd/compile/internal/devirtualize/devirtualize.go +++ b/src/cmd/compile/internal/devirtualize/devirtualize.go @@ -223,7 +223,7 @@ func concreteType1(s *State, n ir.Node, seen map[*ir.Name]struct{}) (outT *types switch n1 := n.(type) { case *ir.ConvExpr: if n1.Op() == ir.OCONVNOP { - if !n1.Type().IsInterface() || !types.Identical(n1.Type(), n1.X.Type()) { + if !n1.Type().IsInterface() || !types.Identical(n1.Type().Underlying(), n1.X.Type().Underlying()) { // As we check (directly before this switch) whether n is an interface, thus we should only reach // here for iface conversions where both operands are the same. base.Fatalf("not identical/interface types found n1.Type = %v; n1.X.Type = %v", n1.Type(), n1.X.Type()) diff --git a/test/devirtualization.go b/test/devirtualization.go index e331905294..edabb94108 100644 --- a/test/devirtualization.go +++ b/test/devirtualization.go @@ -1139,6 +1139,12 @@ func devirtWrapperType() { var a A = (implWrapper)(i) // ERROR "implWrapper\(i\) does not escape$" a.A() // ERROR "devirtualizing a.A to implWrapper$" "inlining call to implWrapper.A" } + { + type anyWrapper any + var foo any = &Impl{} // ERROR "&Impl\{\} does not escape" + var bar anyWrapper = foo + bar.(M).M() // ERROR "devirtualizing bar\.\(M\).M to \*Impl" "inlining call to \(\*Impl\)\.M" + } } func selfAssigns() {