Source file
test/typeparam/issue51522b.go
1
2
3
4
5
6
7 package main
8
9 func f[T comparable](i any) {
10 var t T
11
12 switch i {
13 case t:
14
15 default:
16 println("FAIL: switch i")
17 }
18
19 switch t {
20 case i:
21
22 default:
23 println("FAIL: switch t")
24 }
25 }
26
27 type myint int
28
29 func (m myint) foo() {
30 }
31
32 type fooer interface {
33 foo()
34 }
35
36 type comparableFoo interface {
37 comparable
38 foo()
39 }
40
41 func g[T comparableFoo](i fooer) {
42 var t T
43
44 switch i {
45 case t:
46
47 default:
48 println("FAIL: switch i")
49 }
50
51 switch t {
52 case i:
53
54 default:
55 println("FAIL: switch t")
56 }
57 }
58
59 func main() {
60 f[int](0)
61 g[myint](myint(0))
62 }
63
View as plain text