Skip to content

Commit 7c83b0e

Browse files
committed
Move comment and clarify
1 parent 1e74b7a commit 7c83b0e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

go/extractor/extractor.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,13 @@ func extractObjects(tw *trap.Writer, scope *types.Scope, scopeLabel trap.Label)
477477
}
478478
// Populate type parameter parents for named types.
479479
if typeNameObj, ok := obj.(*types.TypeName); ok {
480+
// `types.TypeName` represents a type with a name: a defined
481+
// type, an alias type, a type parameter, or a predeclared
482+
// type such as `int` or `error`. We can distinguish these
483+
// using `typeNameObj.Type()`, except that we need to be
484+
// careful with alias types because before Go 1.24 they would
485+
// return the underlying type.
480486
if tp, ok := typeNameObj.Type().(*types.Named); ok && !typeNameObj.IsAlias() {
481-
// `typeNameObj` can only be an alias in versions of Go
482-
// before 1.24.
483487
populateTypeParamParents(tp.TypeParams(), obj)
484488
} else if tp, ok := typeNameObj.Type().(*types.Alias); ok {
485489
populateTypeParamParents(tp.TypeParams(), obj)

0 commit comments

Comments
 (0)