@@ -1507,9 +1507,24 @@ func extractSpec(tw *trap.Writer, spec ast.Spec, parent trap.Label, idx int) {
15071507 extractNodeLocation (tw , spec , lbl )
15081508}
15091509
1510+ // Determines whether the given type is an alias.
1511+ func isAlias (tp types.Type ) bool {
1512+ _ , ok := tp .(* types.Alias )
1513+ return ok
1514+ }
1515+
1516+ // If the given type is a type alias, this function resolves it to its underlying type.
1517+ func resolveTypeAlias (tp types.Type ) types.Type {
1518+ if isAlias (tp ) {
1519+ return types .Unalias (tp ) // tp.Underlying()
1520+ }
1521+ return tp
1522+ }
1523+
15101524// extractType extracts type information for `tp` and returns its associated label;
15111525// types are only extracted once, so the second time `extractType` is invoked it simply returns the label
15121526func extractType (tw * trap.Writer , tp types.Type ) trap.Label {
1527+ tp = resolveTypeAlias (tp )
15131528 lbl , exists := getTypeLabel (tw , tp )
15141529 if ! exists {
15151530 var kind int
@@ -1666,6 +1681,7 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
16661681// is constructed from their globally unique ID. This prevents cyclic type keys
16671682// since type recursion in Go always goes through named types.
16681683func getTypeLabel (tw * trap.Writer , tp types.Type ) (trap.Label , bool ) {
1684+ tp = resolveTypeAlias (tp )
16691685 lbl , exists := tw .Labeler .TypeLabels [tp ]
16701686 if ! exists {
16711687 switch tp := tp .(type ) {
0 commit comments