File tree 1 file changed +21
-8
lines changed
1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -18,26 +18,39 @@ type I interface {
18
18
M ()
19
19
}
20
20
21
- func main (){
21
+ func main () {
22
22
var x I
23
23
switch x .(type ) {
24
- case string : // ERROR "impossible"
24
+ case string : // ERROR "impossible"
25
25
println ("FAIL" )
26
26
}
27
-
27
+
28
28
// Issue 2700: if the case type is an interface, nothing is impossible
29
-
29
+
30
30
var r io.Reader
31
-
31
+
32
32
_ , _ = r .(io.Writer )
33
-
33
+
34
34
switch r .(type ) {
35
35
case io.Writer :
36
36
}
37
-
37
+
38
38
// Issue 2827.
39
- switch _ := r .(type ) { // ERROR "invalid variable name _|no new variables"
39
+ switch _ := r .(type ) { // ERROR "invalid variable name _|no new variables"
40
40
}
41
41
}
42
42
43
+ func noninterface () {
44
+ var i int
45
+ switch i .(type ) { // ERROR "cannot type switch on non-interface value"
46
+ case string :
47
+ case int :
48
+ }
43
49
50
+ type S struct {
51
+ name string
52
+ }
53
+ var s S
54
+ switch s .(type ) { // ERROR "cannot type switch on non-interface value"
55
+ }
56
+ }
You can’t perform that action at this time.
0 commit comments