Debian Codegraph @

staticcheck/sa5010/testdata/go1.0/CheckImpossibleTypeAssertion/CheckImpossibleTypeAssertion.go

raw
1 package pkg
2
3 import "fmt"
4
5 type i1 interface {
6 String() int
7 }
8
9 type i2 interface {
10 String() string
11 }
12
13 type i3 interface {
14 bar() int
15 }
16
17 type i4 interface {
18 String() int
19 bar() int
20 }
21
22 func fn() {
23 var v1 i1
24 _ = v1.(i2) //@ diag(`impossible type assertion; i1 and i2 contradict each other`)
25 _ = v1.(i3)
26 _ = v1.(i4)
27 _ = v1.(fmt.Stringer) //@ diag(`impossible type assertion; i1 and fmt.Stringer contradict each other`)
28 _ = v1.(interface { //@ diag(re`i1 and.+String.+contradict each other`)
29 String() string
30 })
31 }