Files
golang.go/test/fixedbugs/issue78404.go
Mateusz Poliwczak 09031d907c cmd/compile/internal/devirtualize: use pointer identity for type comparison
Fixes #78404

Change-Id: I6adc1fb42ad6a3acce21333c6819d0796a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/760161
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2026-03-30 07:27:52 -07:00

38 lines
601 B
Go

// run
// Copyright 2026 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 Iface[IO any] interface {
Foo()
}
type underlyingIfaceImpl struct{}
func (e *underlyingIfaceImpl) Foo() {}
type Impl1[IO any] struct {
underlyingIfaceImpl
}
type Impl2 struct {
underlyingIfaceImpl
}
func NewImpl1[IO any]() Iface[IO] {
return &Impl1[IO]{}
}
var alwaysFalse = false
func main() {
val := NewImpl1[int]()
if alwaysFalse { // dead branch
val = &Impl2{}
}
val.Foo() // must not panic
}