From fe6d3648aeeeb56f66e8080659f8145f6ffda63c Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Thu, 22 Aug 2024 15:53:51 +0100 Subject: [PATCH] Update labels for alias types Use object like we do for named types. --- go/extractor/extractor.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/go/extractor/extractor.go b/go/extractor/extractor.go index c57d0317476..3712b7c9393 100644 --- a/go/extractor/extractor.go +++ b/go/extractor/extractor.go @@ -1789,13 +1789,18 @@ func getTypeLabel(tw *trap.Writer, tp types.Type) (trap.Label, bool) { } lbl = tw.Labeler.GlobalID(fmt.Sprintf("%s;typesetliteraltype", b.String())) case *types.Alias: - var b strings.Builder - b.WriteString(tp.Obj().Id()) - // Ensure that the definition of the alias gets extracted, - // which may be an alias in itself. + // Ensure that the definition of the aliased type gets extracted + // (which may be an alias in itself). extractType(tw, tp.Rhs()) - // Construct the label for this type alias. - lbl = tw.Labeler.GlobalID(fmt.Sprintf("%s;typealias", b.String())) + + entitylbl, exists := tw.Labeler.LookupObjectID(tp.Obj(), lbl) + if entitylbl == trap.InvalidLabel { + panic(fmt.Sprintf("Cannot construct label for alias type %v (underlying object is %v).\n", tp, tp.Obj())) + } + if !exists { + extractObject(tw, tp.Obj(), entitylbl) + } + lbl = tw.Labeler.GlobalID(fmt.Sprintf("{%s};aliastype", entitylbl)) default: log.Fatalf("(getTypeLabel) unexpected type %T", tp) }