From c7c975809b53b8af0012a71334fa63c37348f592 Mon Sep 17 00:00:00 2001 From: Daniel Morsing Date: Sat, 22 Sep 2012 05:54:37 +1000 Subject: [PATCH] [release-branch.go1] cmd/gc: Don't claim type assertion would help when it wont. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ««« 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 | 2 +- test/interface/explicit.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c index b56e848db7..c264974241 100644 --- a/src/cmd/gc/subr.c +++ b/src/cmd/gc/subr.c @@ -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; } diff --git a/test/interface/explicit.go b/test/interface/explicit.go index d19480a685..7822b88d08 100644 --- a/test/interface/explicit.go +++ b/test/interface/explicit.go @@ -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" -- 2.50.0