Skip to content

Commit 4f8bc62

Browse files
mdempskygopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 5c682f9 commit 4f8bc62

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,7 @@ func Call(call *ir.CallExpr) {
152152
default:
153153
call.SetType(ft.Results())
154154
}
155+
156+
// Desugar OCALLMETH, if we created one (#57309).
157+
typecheck.FixMethodCall(call)
155158
}

test/fixedbugs/issue57309.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// run
2+
3+
// Copyright 2022 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package main
8+
9+
type I interface {
10+
M()
11+
}
12+
13+
type S struct {
14+
}
15+
16+
func (*S) M() {
17+
}
18+
19+
func main() {
20+
func() {
21+
I(&S{}).M()
22+
}()
23+
}

0 commit comments

Comments
 (0)