From f067c34934cac10bb85820bc236efcf416176daa Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 9 Jun 2010 11:00:55 -0700 Subject: gc: more cleanup * disallow surrogate pair runes. * diagnose impossible type assertions * eliminate another static buffer. * do not overflow lexbuf. * add -u flag to disable package unsafe. R=ken2 CC=golang-dev http://codereview.appspot.com/1619042 --- test/interface/explicit.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'test/interface') diff --git a/test/interface/explicit.go b/test/interface/explicit.go index 797cec80e..120135cb6 100644 --- a/test/interface/explicit.go +++ b/test/interface/explicit.go @@ -1,4 +1,4 @@ -// errchk $G $D/$F.go +// errchk $G -e $D/$F.go // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style @@ -50,3 +50,22 @@ func main() { e = E(t) // ok t = T(e) // ERROR "need explicit|need type assertion|incompatible" } + +type M interface { M() } +var m M + +var _ = m.(int) // ERROR "impossible type assertion" + +type Int int +func (Int) M(float) {} + +var _ = m.(Int) // ERROR "impossible type assertion" + +var ii int +var jj Int + +var m1 M = ii // ERROR "missing" +var m2 M = jj // ERROR "wrong type for M method" + +var m3 = M(ii) // ERROR "missing" +var m4 = M(jj) // ERROR "wrong type for M method" -- cgit v1.2.3