]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile: delay method value wrapper generation until walk
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Sat, 26 Jun 2021 18:31:03 +0000 (01:31 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Sun, 27 Jun 2021 09:38:56 +0000 (09:38 +0000)
As walk already create the wrapper if necessary.

With this change, test/inline.go need to be changed to use
errorcheckwithauto, for matching "inlining call to ..." in autogenerated
position for method value wrapper, since when we don't generate the
wrapper immediately during typecheck.

Change-Id: I9ffbec9ad3c2b7295546976e2fa517336c13c89b
Reviewed-on: https://go-review.googlesource.com/c/go/+/330838
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/typecheck/expr.go
test/inline.go

index f039cbab08d485c2b4a4e8cad32035db41e90ab1..7e974dfda863a0bc378d68fc0be98a8ec30bb222 100644 (file)
@@ -542,7 +542,7 @@ func tcDot(n *ir.SelectorExpr, top int) ir.Node {
 
        if (n.Op() == ir.ODOTINTER || n.Op() == ir.ODOTMETH) && top&ctxCallee == 0 {
                n.SetOp(ir.OMETHVALUE)
-               n.SetType(MethodValueWrapper(n).Type())
+               n.SetType(NewMethodType(n.Type(), nil))
        }
        return n
 }
index 472a941dca3a66a47b0b2a6679bb921bc1cbc8b3..2cda07b2da9b0cbb727cff1ea9e88d208730bf4b 100644 (file)
@@ -1,4 +1,4 @@
-// errorcheck -0 -m -d=inlfuncswithclosures=1
+// errorcheckwithauto -0 -m -d=inlfuncswithclosures=1
 
 // Copyright 2015 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
@@ -169,6 +169,7 @@ func k() (T, int, int) { return T{}, 0, 0 } // ERROR "can inline k"
 
 func _() { // ERROR "can inline _"
        T.meth(k()) // ERROR "inlining call to k" "inlining call to T.meth"
+       // ERRORAUTO "inlining call to T.meth"
 }
 
 func small1() { // ERROR "can inline small1"
@@ -232,12 +233,13 @@ Loop:
 // Issue #18493 - make sure we can do inlining of functions with a method value
 type T1 struct{}
 
-func (a T1) meth(val int) int { // ERROR "can inline T1.meth" "inlining call to T1.meth"
+func (a T1) meth(val int) int { // ERROR "can inline T1.meth"
        return val + 5
 }
 
 func getMeth(t1 T1) func(int) int { // ERROR "can inline getMeth"
        return t1.meth // ERROR "t1.meth escapes to heap"
+       // ERRORAUTO "inlining call to T1.meth"
 }
 
 func ii() { // ERROR "can inline ii"