]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1] cmd/gc: Don't claim type assertion would help when it wont.
authorDaniel Morsing <daniel.morsing@gmail.com>
Fri, 21 Sep 2012 19:54:37 +0000 (05:54 +1000)
committerIan Lance Taylor <iant@golang.org>
Fri, 21 Sep 2012 19:54:37 +0000 (05:54 +1000)
««« backport b76339cc168a
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

»»»

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

index b56e848db700456b15b8151a4a1e99ef8c0257d1..c264974241d12bb154e365e53717d7ad1c06e249 100644 (file)
@@ -1214,7 +1214,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"