1
0
mirror of https://github.com/golang/go synced 2024-11-25 06:47:56 -07:00

cmd/gc: fix PkgPath of byte, rune types

Fixes #3853.

R=ken2
CC=golang-dev
https://golang.org/cl/6492071
This commit is contained in:
Russ Cox 2012-09-01 19:55:55 -04:00
parent 9b8c94a46f
commit a96c2b8c1a
2 changed files with 29 additions and 0 deletions

View File

@ -680,6 +680,12 @@ dtypesym(Type *t)
Sig *a, *m; Sig *a, *m;
Type *t1, *tbase, *t2; 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)) if(isideal(t))
fatal("dtypesym %T", t); fatal("dtypesym %T", t);

View File

@ -1384,7 +1384,30 @@ func TestImportPath(t *testing.T) {
path string path string
}{ }{
{TypeOf(&base64.Encoding{}).Elem(), "encoding/base64"}, {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(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(map[string]int{}), ""},
{TypeOf((*error)(nil)).Elem(), ""}, {TypeOf((*error)(nil)).Elem(), ""},
} }