mirror of
https://github.com/golang/go
synced 2024-11-24 13:40:19 -07:00
f4198f85d5
This CL extends unified IR to handle creating wrapper methods. There's relatively little about this code that's actually specific to unified IR, but rewriting this logic allows a few benefits: 1. It decouples unified IR from reflectdata.methodWrapper, so the latter code can evolve freely for -G=3's needs. This will also allow the new code to evolve to unified IR's wrapper needs, which I anticipate will operate slightly differently. 2. It provided an opportunity to revisit a lot of the code and simplify/update it to current style. E.g., in the process, I discovered #46903, which unified IR now gets correctly. (I have not yet attempted to fix reflectdata.methodWrapper.) 3. It gives a convenient way for unified IR to ensure all of the wrapper methods it needs are generated correctly. For now, the wrapper generation is specific to non-quirks mode. Change-Id: I5798de6b141f29e8eb6a5c563e7049627ff2868a Reviewed-on: https://go-review.googlesource.com/c/go/+/330569 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
33 lines
594 B
Go
33 lines
594 B
Go
// run
|
|
//go:build goexperiment.unified
|
|
// +build goexperiment.unified
|
|
|
|
// TODO(mdempsky): Enable test unconditionally. This test should pass
|
|
// for non-unified mode too.
|
|
|
|
// Copyright 2021 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
|
|
|
|
//go:notinheap
|
|
type A struct{ B }
|
|
type B struct{ x byte }
|
|
type I interface{ M() *B }
|
|
|
|
func (p *B) M() *B { return p }
|
|
|
|
var (
|
|
a A
|
|
i I = &a
|
|
)
|
|
|
|
func main() {
|
|
got, want := i.M(), &a.B
|
|
if got != want {
|
|
println(got, "!=", want)
|
|
panic("FAIL")
|
|
}
|
|
}
|