blob: e11da7d747f9ec6802cfe7b98ba51ae5e78b2ae5 [file] [log] [blame]
Luuk van Dijk13e92e42011-11-09 10:58:53 +01001// errchk $G -e $D/$F.go
2
3// Copyright 2011 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7package main
8
Luuk van Dijk0e919ff2012-01-24 13:53:00 +01009import (
10 "io"
11)
Luuk van Dijk13e92e42011-11-09 10:58:53 +010012
13type I interface {
Luuk van Dijk0e919ff2012-01-24 13:53:00 +010014 M()
Luuk van Dijk13e92e42011-11-09 10:58:53 +010015}
16
17func main(){
Luuk van Dijk0e919ff2012-01-24 13:53:00 +010018 var x I
19 switch x.(type) {
20 case string: // ERROR "impossible"
21 println("FAIL")
22 }
23
24 // Issue 2700: if the case type is an interface, nothing is impossible
25
26 var r io.Reader
27
28 _, _ = r.(io.Writer)
29
30 switch r.(type) {
31 case io.Writer:
32 }
Russ Cox74ee51e2012-02-06 12:35:29 -050033
34 // Issue 2827.
35 switch _ := r.(type) { // ERROR "invalid variable name _"
36 }
Luuk van Dijk13e92e42011-11-09 10:58:53 +010037}
Luuk van Dijk0e919ff2012-01-24 13:53:00 +010038
39