]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/devirtualize: fix OCONVNOP assertion
authorMateusz Poliwczak <mpoliwczak34@gmail.com>
Sun, 12 Oct 2025 09:15:11 +0000 (11:15 +0200)
committerMateusz Poliwczak <mpoliwczak34@gmail.com>
Tue, 14 Oct 2025 16:33:37 +0000 (09:33 -0700)
Fixes #75863

Change-Id: I1e5a0f3880dcd5f820a5b6f4540c49b16a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/711141
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Lasse Folger <lassefolger@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/devirtualize/devirtualize.go
test/devirtualization.go

index 9d4160085edde95d17885da0ed907d24ed8a32b3..363cd6f2e5d17ae489331700ce7ec5705941b083 100644 (file)
@@ -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())
index e3319052945e00ccb3ab6e65765d4fc78d13b6b3..edabb94108d02d1b6c1ab327f18b748df03cc62e 100644 (file)
@@ -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() {