yyerror("%lN is not a type", ll->n);
// reset to original type
ll->n = n->ntest->right;
- } else if(!implements(ll->n->type, t, &missing, &have, &ptr)) {
+ } else if(ll->n->type->etype != TINTER && !implements(ll->n->type, t, &missing, &have, &ptr)) {
if(have && !missing->broke && !have->broke)
yyerror("impossible type switch case: %lN cannot have dynamic type %T"
" (wrong type for %S method)\n\thave %S%hT\n\twant %S%hT",
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:
+ }
}
+
+