]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] transformDot() should set Selection and tc flag for added ODOTs
authorDan Scales <danscales@google.com>
Sun, 18 Jul 2021 18:10:41 +0000 (11:10 -0700)
committerDan Scales <danscales@google.com>
Sat, 24 Jul 2021 17:58:49 +0000 (17:58 +0000)
Fixes -G=3 issue with issue44688.go.

Change-Id: Ie98c0cbd48683dedd115332043f14c8f3160f46c
Reviewed-on: https://go-review.googlesource.com/c/go/+/337029
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>

src/cmd/compile/internal/noder/transform.go
test/run.go

index f89ae132379c3da4beff0cd693a5092e35219892..2fe55a6852fff5ea9517304ddcb37f87e1049fa0 100644 (file)
@@ -591,6 +591,24 @@ func transformDot(n *ir.SelectorExpr, isCall bool) ir.Node {
        if n.Op() == ir.OXDOT {
                n = typecheck.AddImplicitDots(n)
                n.SetOp(ir.ODOT)
+
+               // Set the Selection field and typecheck flag for any new ODOT nodes
+               // added by AddImplicitDots(), and also transform to ODOTPTR if
+               // needed. Equivalent to 'n.X = typecheck(n.X, ctxExpr|ctxType)' in
+               // tcDot.
+               for n1 := n; n1.X.Op() == ir.ODOT; {
+                       n1 = n1.X.(*ir.SelectorExpr)
+                       if !n1.Implicit() {
+                               break
+                       }
+                       t1 := n1.X.Type()
+                       if t1.IsPtr() && !t1.Elem().IsInterface() {
+                               t1 = t1.Elem()
+                               n1.SetOp(ir.ODOTPTR)
+                       }
+                       typecheck.Lookdot(n1, t1, 0)
+                       n1.SetTypecheck(1)
+               }
        }
 
        t := n.X.Type()
index 5624654fec97154041018aaec2f93a7c3b2e012c..1e7fab4359d022ec6d050573739b4772a52c3fa1 100644 (file)
@@ -2185,8 +2185,7 @@ var g3Failures = setOf(
        "typeparam/mdempsky/4.go",  // -G=3 can't export functions with labeled breaks in loops
        "typeparam/mdempsky/13.go", // problem with interface as as a type arg.
 
-       "typeparam/cons.go",       // causes an unreachable method
-       "typeparam/issue44688.go", // interface conversion fails due to missing method
+       "typeparam/cons.go", // causes an unreachable method
 )
 
 var unifiedFailures = setOf(