Skip to content

Commit 7d55f04

Browse files
timothy-kingyangjuncode
authored andcommitted
[release-branch.go1.23] cmd/compile/internal/importer: enable aliases
Flips the pkgReader.enableAlias flag to true when reading unified IR. This was disabled while resolving golang#66873. This resolves the TODO to flip it back to true. Fixes golang#70394 Fixes golang#70517 Updates golang#66873 Change-Id: Ifd52b0f9510d6bcf151de1c9a18d71ab548c14e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/604099 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: David Chase <[email protected]> (cherry picked from commit 209ed1a) Reviewed-on: https://go-review.googlesource.com/c/go/+/631855 Commit-Queue: Tim King <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 194de8f commit 7d55f04

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

src/cmd/compile/internal/importer/gcimporter_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,23 @@ func TestIssue25596(t *testing.T) {
582582
compileAndImportPkg(t, "issue25596")
583583
}
584584

585+
func TestIssue70394(t *testing.T) {
586+
testenv.MustHaveGoBuild(t)
587+
588+
// This package only handles gc export data.
589+
if runtime.Compiler != "gc" {
590+
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
591+
}
592+
593+
pkg := compileAndImportPkg(t, "alias")
594+
obj := lookupObj(t, pkg.Scope(), "A")
595+
596+
typ := obj.Type()
597+
if _, ok := typ.(*types2.Alias); !ok {
598+
t.Fatalf("type of %s is %s, wanted an alias", obj, typ)
599+
}
600+
}
601+
585602
func importPkg(t *testing.T, path, srcDir string) *types2.Package {
586603
pkg, err := Import(make(map[string]*types2.Package), path, srcDir, nil)
587604
if err != nil {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2024 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package testdata
6+
7+
type A = int32

src/cmd/compile/internal/importer/ureader.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input
2929
pr := pkgReader{
3030
PkgDecoder: input,
3131

32-
ctxt: ctxt,
33-
imports: imports,
34-
// Currently, the compiler panics when using Alias types.
35-
// TODO(gri) set to true once this is fixed (issue #66873)
36-
enableAlias: false,
32+
ctxt: ctxt,
33+
imports: imports,
34+
enableAlias: true,
3735

3836
posBases: make([]*syntax.PosBase, input.NumElems(pkgbits.RelocPosBase)),
3937
pkgs: make([]*types2.Package, input.NumElems(pkgbits.RelocPkg)),

0 commit comments

Comments
 (0)