diff options
author | Russ Cox <rsc@golang.org> | 2009-03-04 14:50:25 -0800 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-03-04 14:50:25 -0800 |
commit | 42510203e676db559c35a6219ab8e94bd5a5f111 (patch) | |
tree | c67a83bee157b7f51073f7faae0de31cae646c3f /src | |
parent | 82c06385294dec65f107b242ede8c0d9a99795ba (diff) | |
download | golang-42510203e676db559c35a6219ab8e94bd5a5f111.tar.gz |
disallow ordinary-type.(T), as in spec.
R=ken
OCL=25705
CL=25705
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/gc/walk.c | 3 | ||||
-rw-r--r-- | src/lib/reflect/type.go | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index c7deefc91..3ae0f52f7 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -2851,6 +2851,9 @@ ifaceas1(Type *dst, Type *src, int explicit) if(src == T || dst == T) return Inone; + if(explicit && !isinter(src)) + yyerror("cannot use .(T) on non-interface type %T", src); + if(isinter(dst)) { if(isinter(src)) { if(eqtype(dst, src, 0)) diff --git a/src/lib/reflect/type.go b/src/lib/reflect/type.go index 438f5b232..96953f3b0 100644 --- a/src/lib/reflect/type.go +++ b/src/lib/reflect/type.go @@ -107,7 +107,8 @@ func newBasicType(name string, kind int, size int) Type { // Prebuilt basic types var ( Missing = newBasicType(missingString, MissingKind, 1); - DotDotDot = newBasicType(dotDotDotString, DotDotDotKind, unsafe.Sizeof(true.(interface{}))); + empty interface{}; + DotDotDot = newBasicType(dotDotDotString, DotDotDotKind, unsafe.Sizeof(empty)); Bool = newBasicType("bool", BoolKind, unsafe.Sizeof(true)); Int = newBasicType("int", IntKind, unsafe.Sizeof(int(0))); Int8 = newBasicType("int8", Int8Kind, 1); |