mirror of
https://github.com/golang/go.git
synced 2026-04-02 17:30:01 +09:00
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>
38 lines
601 B
Go
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
|
|
}
|