Source file
test/fixedbugs/issue78404.go
1
2
3
4
5
6
7 package main
8
9 type Iface[IO any] interface {
10 Foo()
11 }
12
13 type underlyingIfaceImpl struct{}
14
15 func (e *underlyingIfaceImpl) Foo() {}
16
17 type Impl1[IO any] struct {
18 underlyingIfaceImpl
19 }
20
21 type Impl2 struct {
22 underlyingIfaceImpl
23 }
24
25 func NewImpl1[IO any]() Iface[IO] {
26 return &Impl1[IO]{}
27 }
28
29 var alwaysFalse = false
30
31 func main() {
32 val := NewImpl1[int]()
33 if alwaysFalse {
34 val = &Impl2{}
35 }
36 val.Foo()
37 }
38
View as plain text