Skip to content

Commit 6b541dd

Browse files
owen-mcmbg
authored andcommitted
Update labels for alias types
Use object like we do for named types.
1 parent 7422281 commit 6b541dd

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

go/extractor/extractor.go

+11-6
Original file line numberDiff line numberDiff line change
@@ -1789,13 +1789,18 @@ func getTypeLabel(tw *trap.Writer, tp types.Type) (trap.Label, bool) {
17891789
}
17901790
lbl = tw.Labeler.GlobalID(fmt.Sprintf("%s;typesetliteraltype", b.String()))
17911791
case *types.Alias:
1792-
var b strings.Builder
1793-
b.WriteString(tp.Obj().Id())
1794-
// Ensure that the definition of the alias gets extracted,
1795-
// which may be an alias in itself.
1792+
// Ensure that the definition of the aliased type gets extracted
1793+
// (which may be an alias in itself).
17961794
extractType(tw, tp.Rhs())
1797-
// Construct the label for this type alias.
1798-
lbl = tw.Labeler.GlobalID(fmt.Sprintf("%s;typealias", b.String()))
1795+
1796+
entitylbl, exists := tw.Labeler.LookupObjectID(tp.Obj(), lbl)
1797+
if entitylbl == trap.InvalidLabel {
1798+
panic(fmt.Sprintf("Cannot construct label for alias type %v (underlying object is %v).\n", tp, tp.Obj()))
1799+
}
1800+
if !exists {
1801+
extractObject(tw, tp.Obj(), entitylbl)
1802+
}
1803+
lbl = tw.Labeler.GlobalID(fmt.Sprintf("{%s};aliastype", entitylbl))
17991804
default:
18001805
log.Fatalf("(getTypeLabel) unexpected type %T", tp)
18011806
}

0 commit comments

Comments
 (0)