| 1 |
package pkg |
| 2 |
|
| 3 |
type ExampleType[T uint32 | uint64] interface { |
| 4 |
SomeMethod() T |
| 5 |
} |
| 6 |
|
| 7 |
func Fn1[T uint32 | uint64]() { |
| 8 |
var iface ExampleType[uint32] |
| 9 |
_ = iface.(ExampleType[T]) |
| 10 |
} |
| 11 |
|
| 12 |
func Fn2[T uint64]() { |
| 13 |
var iface ExampleType[uint32] |
| 14 |
// TODO(dh): once we support generics, flag this |
| 15 |
_ = iface.(ExampleType[T]) |
| 16 |
} |
| 17 |
|
| 18 |
type I1[E any] interface { |
| 19 |
Do(E) |
| 20 |
Moo(E) |
| 21 |
} |
| 22 |
|
| 23 |
type I2[E any] interface { |
| 24 |
Do(E) |
| 25 |
Moo(E) |
| 26 |
} |
| 27 |
|
| 28 |
type I3[E any] interface { |
| 29 |
Do(E) |
| 30 |
Moo() |
| 31 |
} |
| 32 |
|
| 33 |
func New[T any]() { |
| 34 |
var x I1[T] |
| 35 |
_ = x.(I2[T]) |
| 36 |
|
| 37 |
// TODO(dh): once we support generics, flag this |
| 38 |
_ = x.(I3[T]) |
| 39 |
} |