From 57fad4a837d0d31fe09f70f5026b4ae5fe929dd3 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Fri, 24 Jan 2025 09:40:58 +0000 Subject: [PATCH 1/2] Allow type parameters on alias types --- go/extractor/extractor.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/go/extractor/extractor.go b/go/extractor/extractor.go index c0eef233ba58..8b52be4553e3 100644 --- a/go/extractor/extractor.go +++ b/go/extractor/extractor.go @@ -475,12 +475,12 @@ func extractObjects(tw *trap.Writer, scope *types.Scope, scopeLabel trap.Label) populateTypeParamParents(funcObj.Type().(*types.Signature).TypeParams(), obj) populateTypeParamParents(funcObj.Type().(*types.Signature).RecvTypeParams(), obj) } - // Populate type parameter parents for named types. Note that we - // skip type aliases as the original type should be the parent - // of any type parameters. - if typeNameObj, ok := obj.(*types.TypeName); ok && !typeNameObj.IsAlias() { + // Populate type parameter parents for named types. + if typeNameObj, ok := obj.(*types.TypeName); ok { if tp, ok := typeNameObj.Type().(*types.Named); ok { populateTypeParamParents(tp.TypeParams(), obj) + } else if tp, ok := typeNameObj.Type().(*types.Alias); ok { + populateTypeParamParents(tp.TypeParams(), obj) } } extractObject(tw, obj, lbl) From 29f6d481627a3c0675090117b4ea8cdf8a543d5e Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Fri, 24 Jan 2025 12:30:27 +0000 Subject: [PATCH 2/2] Retain previous check for alias types --- go/extractor/extractor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/extractor/extractor.go b/go/extractor/extractor.go index 8b52be4553e3..e4059e3e90c1 100644 --- a/go/extractor/extractor.go +++ b/go/extractor/extractor.go @@ -477,7 +477,7 @@ func extractObjects(tw *trap.Writer, scope *types.Scope, scopeLabel trap.Label) } // Populate type parameter parents for named types. if typeNameObj, ok := obj.(*types.TypeName); ok { - if tp, ok := typeNameObj.Type().(*types.Named); ok { + if tp, ok := typeNameObj.Type().(*types.Named); ok && !typeNameObj.IsAlias() { populateTypeParamParents(tp.TypeParams(), obj) } else if tp, ok := typeNameObj.Type().(*types.Alias); ok { populateTypeParamParents(tp.TypeParams(), obj)