Move comment and clarify

This commit is contained in:
Owen Mansel-Chan
2025-02-11 22:03:44 +00:00
parent 1e74b7af75
commit 7c83b0e213

View File

@@ -477,9 +477,13 @@ 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 {
// `types.TypeName` represents a type with a name: a defined
// type, an alias type, a type parameter, or a predeclared
// type such as `int` or `error`. We can distinguish these
// using `typeNameObj.Type()`, except that we need to be
// careful with alias types because before Go 1.24 they would
// return the underlying type.
if tp, ok := typeNameObj.Type().(*types.Named); ok && !typeNameObj.IsAlias() {
// `typeNameObj` can only be an alias in versions of Go
// before 1.24.
populateTypeParamParents(tp.TypeParams(), obj)
} else if tp, ok := typeNameObj.Type().(*types.Alias); ok {
populateTypeParamParents(tp.TypeParams(), obj)