go/types: unsafe.Pointer is not an alias

Change-Id: Ieb0808caa24c9a5e599084183ba5ee8a6536f7d8
Reviewed-on: https://go-review.googlesource.com/36622
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Alan Donovan 2017-02-09 14:51:29 -05:00
parent d03c124860
commit a896869a49
2 changed files with 5 additions and 0 deletions

View File

@ -164,6 +164,10 @@ func (obj *TypeName) IsAlias() bool {
case nil:
return false
case *Basic:
// unsafe.Pointer is not an alias.
if obj.pkg == Unsafe {
return false
}
// Any user-defined type name for a basic type is an alias for a
// basic type (because basic types are pre-declared in the Universe
// scope, outside any package scope), and so is any type name with

View File

@ -14,6 +14,7 @@ func TestIsAlias(t *testing.T) {
}
// predeclared types
check(Unsafe.Scope().Lookup("Pointer").(*TypeName), false)
for _, name := range Universe.Names() {
if obj, _ := Universe.Lookup(name).(*TypeName); obj != nil {
check(obj, name == "byte" || name == "rune")