]> Cypherpunks.ru repositories - gostls13.git/blob - test/typeparam/issue51522b.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / typeparam / issue51522b.go
1 // run
2
3 // Copyright 2022 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 func f[T comparable](i any) {
10         var t T
11
12         switch i {
13         case t:
14                 // ok
15         default:
16                 println("FAIL: switch i")
17         }
18
19         switch t {
20         case i:
21                 // ok
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                 // ok
47         default:
48                 println("FAIL: switch i")
49         }
50
51         switch t {
52         case i:
53                 // ok
54         default:
55                 println("FAIL: switch t")
56         }
57 }
58
59 func main() {
60         f[int](0)
61         g[myint](myint(0))
62 }