mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/devirtualize: fix OCONVNOP assertion
Fixes #75863 Change-Id: I1e5a0f3880dcd5f820a5b6f4540c49b16a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/711141 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Lasse Folger <lassefolger@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
3765758b96
commit
5a9ef44bc0
2 changed files with 7 additions and 1 deletions
|
|
@ -223,7 +223,7 @@ func concreteType1(s *State, n ir.Node, seen map[*ir.Name]struct{}) (outT *types
|
||||||
switch n1 := n.(type) {
|
switch n1 := n.(type) {
|
||||||
case *ir.ConvExpr:
|
case *ir.ConvExpr:
|
||||||
if n1.Op() == ir.OCONVNOP {
|
if n1.Op() == ir.OCONVNOP {
|
||||||
if !n1.Type().IsInterface() || !types.Identical(n1.Type(), n1.X.Type()) {
|
if !n1.Type().IsInterface() || !types.Identical(n1.Type().Underlying(), n1.X.Type().Underlying()) {
|
||||||
// As we check (directly before this switch) whether n is an interface, thus we should only reach
|
// As we check (directly before this switch) whether n is an interface, thus we should only reach
|
||||||
// here for iface conversions where both operands are the same.
|
// here for iface conversions where both operands are the same.
|
||||||
base.Fatalf("not identical/interface types found n1.Type = %v; n1.X.Type = %v", n1.Type(), n1.X.Type())
|
base.Fatalf("not identical/interface types found n1.Type = %v; n1.X.Type = %v", n1.Type(), n1.X.Type())
|
||||||
|
|
|
||||||
|
|
@ -1139,6 +1139,12 @@ func devirtWrapperType() {
|
||||||
var a A = (implWrapper)(i) // ERROR "implWrapper\(i\) does not escape$"
|
var a A = (implWrapper)(i) // ERROR "implWrapper\(i\) does not escape$"
|
||||||
a.A() // ERROR "devirtualizing a.A to implWrapper$" "inlining call to implWrapper.A"
|
a.A() // ERROR "devirtualizing a.A to implWrapper$" "inlining call to implWrapper.A"
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
type anyWrapper any
|
||||||
|
var foo any = &Impl{} // ERROR "&Impl\{\} does not escape"
|
||||||
|
var bar anyWrapper = foo
|
||||||
|
bar.(M).M() // ERROR "devirtualizing bar\.\(M\).M to \*Impl" "inlining call to \(\*Impl\)\.M"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func selfAssigns() {
|
func selfAssigns() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue