| 1 |
package c |
| 2 |
|
| 3 |
func instantiated[X any](x *X) int { |
| 4 |
if x == nil { |
| 5 |
print(*x) |
| 6 |
} |
| 7 |
return 1 |
| 8 |
} |
| 9 |
|
| 10 |
var g int |
| 11 |
|
| 12 |
func init() { |
| 13 |
g = instantiated[int](&g) |
| 14 |
} |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
type Empty1 any |
| 19 |
type Empty2 any |
| 20 |
|
| 21 |
|
| 22 |
func TypeParamInterface[T error](x T) { |
| 23 |
if any(x) == nil { |
| 24 |
print() |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
func TypeParamTypeSetWithInt[T interface { |
| 30 |
error |
| 31 |
int |
| 32 |
}](x T) { |
| 33 |
if any(x) == nil { |
| 34 |
print() |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
func TypeParamUnionEmptyEmpty[T Empty1 | Empty2](x T) { |
| 39 |
if any(x) == nil { |
| 40 |
print() |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
func TypeParamUnionEmptyInt[T Empty1 | int](x T) { |
| 45 |
if any(x) == nil { |
| 46 |
print() |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
func TypeParamUnionStringInt[T string | int](x T) { |
| 51 |
if any(x) == nil { |
| 52 |
print() |
| 53 |
} |
| 54 |
} |