summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2012-09-22 05:54:58 +1000
committerRuss Cox <rsc@golang.org>2012-09-22 05:54:58 +1000
commitc516098d45641c1ca0a3ed9957a0e221cd0a18ea (patch)
treecb99d05245a1e81044465a1ba6f7fd81206f7275
parent5b91673fe00e0742b45333aba5c308206d360299 (diff)
downloadgo-c516098d45641c1ca0a3ed9957a0e221cd0a18ea.tar.gz
[release-branch.go1] cmd/gc: fix PkgPath of byte, rune types
??? backport 272e1dd72156 cmd/gc: fix PkgPath of byte, rune types Fixes issue 3853. R=ken2 CC=golang-dev http://codereview.appspot.com/6492071 ???
-rw-r--r--src/cmd/gc/reflect.c6
-rw-r--r--src/pkg/reflect/all_test.go23
2 files changed, 29 insertions, 0 deletions
diff --git a/src/cmd/gc/reflect.c b/src/cmd/gc/reflect.c
index f77697a6b..39f659819 100644
--- a/src/cmd/gc/reflect.c
+++ b/src/cmd/gc/reflect.c
@@ -672,6 +672,12 @@ dtypesym(Type *t)
Sig *a, *m;
Type *t1, *tbase, *t2;
+ // Replace byte, rune aliases with real type.
+ // They've been separate internally to make error messages
+ // better, but we have to merge them in the reflect tables.
+ if(t == bytetype || t == runetype)
+ t = types[t->etype];
+
if(isideal(t))
fatal("dtypesym %T", t);
diff --git a/src/pkg/reflect/all_test.go b/src/pkg/reflect/all_test.go
index e33140563..a0b9a03eb 100644
--- a/src/pkg/reflect/all_test.go
+++ b/src/pkg/reflect/all_test.go
@@ -1384,7 +1384,30 @@ func TestImportPath(t *testing.T) {
path string
}{
{TypeOf(&base64.Encoding{}).Elem(), "encoding/base64"},
+ {TypeOf(int(0)), ""},
+ {TypeOf(int8(0)), ""},
+ {TypeOf(int16(0)), ""},
+ {TypeOf(int32(0)), ""},
+ {TypeOf(int64(0)), ""},
{TypeOf(uint(0)), ""},
+ {TypeOf(uint8(0)), ""},
+ {TypeOf(uint16(0)), ""},
+ {TypeOf(uint32(0)), ""},
+ {TypeOf(uint64(0)), ""},
+ {TypeOf(uintptr(0)), ""},
+ {TypeOf(float32(0)), ""},
+ {TypeOf(float64(0)), ""},
+ {TypeOf(complex64(0)), ""},
+ {TypeOf(complex128(0)), ""},
+ {TypeOf(byte(0)), ""},
+ {TypeOf(rune(0)), ""},
+ {TypeOf([]byte(nil)), ""},
+ {TypeOf([]rune(nil)), ""},
+ {TypeOf(string("")), ""},
+ {TypeOf((*interface{})(nil)).Elem(), ""},
+ {TypeOf((*byte)(nil)), ""},
+ {TypeOf((*rune)(nil)), ""},
+ {TypeOf((*int64)(nil)), ""},
{TypeOf(map[string]int{}), ""},
{TypeOf((*error)(nil)).Elem(), ""},
}