reflect: return correct name for unsafe.Pointer type

For some reason, the type kind name is "unsafe.Pointer" while the
.Name() method just returns "Pointer".

Not sure why this difference exists, but to be able to test .Name() in
testdata/reflect.go it needs to match.
This commit is contained in:
Ayke van Laethem
2024-07-28 19:00:00 +02:00
committed by Ayke
parent 84c376160f
commit 88f9fc3ce2
3 changed files with 97 additions and 92 deletions
+3 -1
View File
@@ -1060,8 +1060,10 @@ func (t *rawType) Name() string {
panic("corrupt name data")
}
if t.Kind() <= UnsafePointer {
if kind := t.Kind(); kind < UnsafePointer {
return t.Kind().String()
} else if kind == UnsafePointer {
return "Pointer"
}
return ""