diff options
author | Robert Griesemer <gri@golang.org> | 2021-02-22 17:02:46 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-02-23 04:13:24 +0000 |
commit | a2e150c7cded1367fb092e87abb37ce2a1673d11 (patch) | |
tree | ac3a31f283ae5060781a871e669135f288ed1d0f /src/cmd/compile/internal/types2/issues_test.go | |
parent | 5a0e4fc4e7188fb36e64a7d7d25bab943f081811 (diff) | |
download | go-a2e150c7cded1367fb092e87abb37ce2a1673d11.tar.gz go-a2e150c7cded1367fb092e87abb37ce2a1673d11.zip |
go/types, cmd/compile/internal/types2: use regular type printing for unsafe.Pointer
Type string printing special-cased printing of unsafe.Pointer because
it's a built-in type; yet it's declared in a package like any other
imported or used-defined type (unlike built-in types such as int).
Use the same mechanism for printing unsafe.Pointer like any other
(non-basic) type. This will make it possible to use the package
Qualifier if so desired.
Fixes #44515.
Change-Id: I0dd1026f850737ecfc4bb99135cfb8e3c18be9e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/295271
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/issues_test.go')
-rw-r--r-- | src/cmd/compile/internal/types2/issues_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types2/issues_test.go b/src/cmd/compile/internal/types2/issues_test.go index a36b832f04..e1f5c92fc4 100644 --- a/src/cmd/compile/internal/types2/issues_test.go +++ b/src/cmd/compile/internal/types2/issues_test.go @@ -546,3 +546,25 @@ func TestIssue43088(t *testing.T) { Comparable(T1) Comparable(T2) } + +func TestIssue44515(t *testing.T) { + typ := Unsafe.Scope().Lookup("Pointer").Type() + + got := TypeString(typ, nil) + want := "unsafe.Pointer" + if got != want { + t.Errorf("got %q; want %q", got, want) + } + + qf := func(pkg *Package) string { + if pkg == Unsafe { + return "foo" + } + return "" + } + got = TypeString(typ, qf) + want = "foo.Pointer" + if got != want { + t.Errorf("got %q; want %q", got, want) + } +} |