Debian Codegraph @

test/typeparam/issue47925b.go

raw
1 // run
2
3 // Copyright 2021 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 package main
8
9 type I[T any] interface {
10 foo()
11 }
12
13 type E[T any] interface {
14 }
15
16 //go:noinline
17 func f[T I[T]](x T) E[T] {
18 // contains a cast from nonempty to empty interface
19 return E[T](I[T](x))
20 }
21
22 type S struct {
23 x int
24 }
25
26 func (s *S) foo() {}
27
28 func main() {
29 i := f(&S{x: 7})
30 if i.(*S).x != 7 {
31 panic("bad")
32 }
33 }