Commit b04c890a authored by Daniel Morsing's avatar Daniel Morsing Committed by Ian Lance Taylor

cmd/gc: Don't claim type assertion would help when it wont.

Fixes #3465.

R=golang-dev, rsc, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/6448097
parent d624f0c9
...@@ -1219,7 +1219,7 @@ assignop(Type *src, Type *dst, char **why) ...@@ -1219,7 +1219,7 @@ assignop(Type *src, Type *dst, char **why)
return 0; return 0;
} }
if(src->etype == TINTER && dst->etype != TBLANK) { if(src->etype == TINTER && dst->etype != TBLANK) {
if(why != nil) if(why != nil && implements(dst, src, &missing, &have, &ptr))
*why = ": need type assertion"; *why = ": need type assertion";
return 0; return 0;
} }
......
...@@ -40,7 +40,7 @@ func main() { ...@@ -40,7 +40,7 @@ func main() {
// because i has an extra method // because i has an extra method
// that t does not, so i cannot contain a t. // that t does not, so i cannot contain a t.
i = t // ERROR "incompatible|missing M method" i = t // ERROR "incompatible|missing M method"
t = i // ERROR "incompatible|need type assertion" t = i // ERROR "incompatible|assignment$"
i = i2 // ok i = i2 // ok
i2 = i // ERROR "incompatible|missing N method" i2 = i // ERROR "incompatible|missing N method"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment