]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: Don't claim type assertion would help when it wont.
authorDaniel Morsing <daniel.morsing@gmail.com>
Wed, 15 Aug 2012 23:53:06 +0000 (16:53 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 15 Aug 2012 23:53:06 +0000 (16:53 -0700)
Fixes #3465.

R=golang-dev, rsc, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/6448097

src/cmd/gc/subr.c
test/interface/explicit.go

index dfb425efcf0d206aa182110823ced40be9f86eae..0cd7e6c4b0d3e42b0b5dfc5243fe98f993479834 100644 (file)
@@ -1219,7 +1219,7 @@ assignop(Type *src, Type *dst, char **why)
                return 0;
        }
        if(src->etype == TINTER && dst->etype != TBLANK) {
-               if(why != nil)
+               if(why != nil && implements(dst, src, &missing, &have, &ptr))
                        *why = ": need type assertion";
                return 0;
        }
index d19480a6856840b6ad597abf968b0b57d73a6bd1..7822b88d0832fc083fb03027c925e96f672ad114 100644 (file)
@@ -40,7 +40,7 @@ func main() {
        // because i has an extra method
        // that t does not, so i cannot contain a t.
        i = t // ERROR "incompatible|missing M method"
-       t = i // ERROR "incompatible|need type assertion"
+       t = i // ERROR "incompatible|assignment$"
 
        i = i2 // ok
        i2 = i // ERROR "incompatible|missing N method"