| 1 |
package pkg |
| 2 |
|
| 3 |
type SomeInterface interface { |
| 4 |
Foo() |
| 5 |
} |
| 6 |
|
| 7 |
func fn(x SomeInterface) { |
| 8 |
_ = x.(SomeInterface) //@ diag(`type assertion to the same type: x already has type SomeInterface`) |
| 9 |
y := x.(SomeInterface) //@ diag(`type assertion to the same type`) |
| 10 |
y = x.(SomeInterface) //@ diag(`type assertion to the same type`) |
| 11 |
var a SomeInterface = x.(SomeInterface) //@ diag(`type assertion to the same type`) |
| 12 |
z, _ := x.(SomeInterface) //@ diag(`type assertion to the same type`) |
| 13 |
z, _ = x.(SomeInterface) //@ diag(`type assertion to the same type`) |
| 14 |
|
| 15 |
_, ok := x.(SomeInterface) //@ diag(`type assertion to the same type`) |
| 16 |
_, ok = x.(SomeInterface) //@ diag(`type assertion to the same type`) |
| 17 |
_, _ = x.(SomeInterface) //@ diag(`type assertion to the same type`) |
| 18 |
|
| 19 |
if z, ok := x.(SomeInterface); ok { //@ diag(`type assertion to the same type`) |
| 20 |
_ = z |
| 21 |
} |
| 22 |
if _, ok := x.(SomeInterface); !ok { //@ diag(`type assertion to the same type`) |
| 23 |
} |
| 24 |
if _, ok = x.(SomeInterface); !ok { //@ diag(`type assertion to the same type`) |
| 25 |
} |
| 26 |
if z, ok = x.(SomeInterface); ok { //@ diag(`type assertion to the same type`) |
| 27 |
} |
| 28 |
if z := x.(SomeInterface); true { //@ diag(`type assertion to the same type`) |
| 29 |
_ = z |
| 30 |
} |
| 31 |
if z, _ := x.(SomeInterface); true { //@ diag(`type assertion to the same type`) |
| 32 |
_ = z |
| 33 |
} |
| 34 |
if _, _ = x.(SomeInterface); true { //@ diag(`type assertion to the same type`) |
| 35 |
} |
| 36 |
if _ = x.(SomeInterface); true { //@ diag(`type assertion to the same type`) |
| 37 |
} |
| 38 |
|
| 39 |
switch x.(type) { |
| 40 |
case SomeInterface: |
| 41 |
} |
| 42 |
|
| 43 |
_ = a |
| 44 |
_ = y |
| 45 |
_ = ok |
| 46 |
_ = z |
| 47 |
} |