Skip to content

Commit 1243ec9

Browse files
cuonglmrandall77
authored andcommitted
cmd/compile: only check implicit dots for method call enabled by a type bound
Fixes #53419 Change-Id: Ibad64f5c4af2112deeb0a9ecc9c589b17594bd05 Reviewed-on: https://go-review.googlesource.com/c/go/+/414836 Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Keith Randall <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]>
1 parent c391156 commit 1243ec9

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/cmd/compile/internal/noder/stencil.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -1654,12 +1654,14 @@ func (g *genInst) getDictionarySym(gf *ir.Name, targs []*types.Type, isMeth bool
16541654
se := call.X.(*ir.SelectorExpr)
16551655
if se.X.Type().IsShape() {
16561656
// This is a method call enabled by a type bound.
1657-
1658-
// We need this extra check for method expressions,
1659-
// which don't add in the implicit XDOTs.
1660-
tmpse := ir.NewSelectorExpr(src.NoXPos, ir.OXDOT, se.X, se.Sel)
1661-
tmpse = typecheck.AddImplicitDots(tmpse)
1662-
tparam := tmpse.X.Type()
1657+
tparam := se.X.Type()
1658+
if call.X.Op() == ir.ODOTMETH {
1659+
// We need this extra check for method expressions,
1660+
// which don't add in the implicit XDOTs.
1661+
tmpse := ir.NewSelectorExpr(src.NoXPos, ir.OXDOT, se.X, se.Sel)
1662+
tmpse = typecheck.AddImplicitDots(tmpse)
1663+
tparam = tmpse.X.Type()
1664+
}
16631665
if !tparam.IsShape() {
16641666
// The method expression is not
16651667
// really on a typeparam.

test/run.go

-1
Original file line numberDiff line numberDiff line change
@@ -1966,7 +1966,6 @@ var types2Failures32Bit = setOf(
19661966
var go118Failures = setOf(
19671967
"typeparam/nested.go", // 1.18 compiler doesn't support function-local types with generics
19681968
"typeparam/issue51521.go", // 1.18 compiler produces bad panic message and link error
1969-
"typeparam/issue53419.go", // 1.18 compiler mishandles generic selector resolution
19701969
)
19711970

19721971
// In all of these cases, the 1.17 compiler reports reasonable errors, but either the

0 commit comments

Comments
 (0)