aboutsummaryrefslogtreecommitdiff
path: root/test/typeswitch3.go
diff options
context:
space:
mode:
authorLuuk van Dijk <lvd@golang.org>2012-01-24 13:53:00 +0100
committerLuuk van Dijk <lvd@golang.org>2012-01-24 13:53:00 +0100
commit0e919ff2c978294c9b0472055b96bb1a09606934 (patch)
treed38ab41015b1f8bbbcb36b30d07a44b5e20f3e8f /test/typeswitch3.go
parent0442087f93d49dec95cd327efbc8c760484ac8bb (diff)
downloadgo-0e919ff2c978294c9b0472055b96bb1a09606934.tar.gz
go-0e919ff2c978294c9b0472055b96bb1a09606934.zip
gc: static implements check on typeswitches only applies to concrete case types.
Fixes #2700. R=rsc CC=golang-dev https://golang.org/cl/5574046
Diffstat (limited to 'test/typeswitch3.go')
-rw-r--r--test/typeswitch3.go27
1 files changed, 21 insertions, 6 deletions
diff --git a/test/typeswitch3.go b/test/typeswitch3.go
index 99d08a20f7..078980146f 100644
--- a/test/typeswitch3.go
+++ b/test/typeswitch3.go
@@ -6,15 +6,30 @@
package main
+import (
+ "io"
+)
type I interface {
- M()
+ M()
}
func main(){
- var x I
- switch x.(type) {
- case string: // ERROR "impossible"
- println("FAIL")
- }
+ var x I
+ switch x.(type) {
+ case string: // ERROR "impossible"
+ println("FAIL")
+ }
+
+ // Issue 2700: if the case type is an interface, nothing is impossible
+
+ var r io.Reader
+
+ _, _ = r.(io.Writer)
+
+ switch r.(type) {
+ case io.Writer:
+ }
}
+
+