From: Matthew Dempsky Date: Wed, 14 Dec 2022 19:48:02 +0000 (-0800) Subject: cmd/compile: desugar OCALLMETH->OCALLFUNC within devirtualization X-Git-Tag: go1.20rc2~1^2~28 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4f8bc6224b64bf7149a03678ab5448830e7df80d;p=gostls13.git cmd/compile: desugar OCALLMETH->OCALLFUNC within devirtualization Devirtualization can turn OCALLINTER into OCALLMETH, but then we want to actually desugar into OCALLFUNC instead for later phases. Just needs a missing call to typecheck.FixMethodCall. Fixes #57309. Change-Id: I331fbd40804e1a370134ef17fa6dd501c0920ed3 Reviewed-on: https://go-review.googlesource.com/c/go/+/457715 Auto-Submit: Matthew Dempsky Reviewed-by: Keith Randall Reviewed-by: Keith Randall Run-TryBot: Matthew Dempsky TryBot-Result: Gopher Robot --- diff --git a/src/cmd/compile/internal/devirtualize/devirtualize.go b/src/cmd/compile/internal/devirtualize/devirtualize.go index 7350a6f171..554e935c3e 100644 --- a/src/cmd/compile/internal/devirtualize/devirtualize.go +++ b/src/cmd/compile/internal/devirtualize/devirtualize.go @@ -152,4 +152,7 @@ func Call(call *ir.CallExpr) { default: call.SetType(ft.Results()) } + + // Desugar OCALLMETH, if we created one (#57309). + typecheck.FixMethodCall(call) } diff --git a/test/fixedbugs/issue57309.go b/test/fixedbugs/issue57309.go new file mode 100644 index 0000000000..ec6a397574 --- /dev/null +++ b/test/fixedbugs/issue57309.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +type I interface { + M() +} + +type S struct { +} + +func (*S) M() { +} + +func main() { + func() { + I(&S{}).M() + }() +}