From cda1e40b44771f8a01f361672cba721d0f283683 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 22 Feb 2024 18:52:39 +0700 Subject: [PATCH] cmd/compile: add missing Unalias call when writing type alias Fixes #65778 Change-Id: I93af42967c7976d63b4f460b7ffbcb9a9c05ffe7 Reviewed-on: https://go-review.googlesource.com/c/go/+/565995 Auto-Submit: Cuong Manh Le LUCI-TryBot-Result: Go LUCI Reviewed-by: Matthew Dempsky Reviewed-by: Robert Griesemer Reviewed-by: Jorropo --- src/cmd/compile/internal/noder/writer.go | 2 +- test/fixedbugs/issue65778.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue65778.go diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go index 87c54b9769..c57ccdf36d 100644 --- a/src/cmd/compile/internal/noder/writer.go +++ b/src/cmd/compile/internal/noder/writer.go @@ -831,7 +831,7 @@ func (w *writer) doObj(wext *writer, obj types2.Object) pkgbits.CodeObj { case *types2.TypeName: if obj.IsAlias() { w.pos(obj) - w.typ(obj.Type()) + w.typ(types2.Unalias(obj.Type())) return pkgbits.ObjAlias } diff --git a/test/fixedbugs/issue65778.go b/test/fixedbugs/issue65778.go new file mode 100644 index 0000000000..30c680404d --- /dev/null +++ b/test/fixedbugs/issue65778.go @@ -0,0 +1,13 @@ +// compile -godebug gotypesalias=1 + +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +type A = int + +type T[P any] *A + +var _ T[int]