go/types, types2: document why Unalias is not needed in some places

Documentation change only.

For #67547.

Change-Id: I0da480299c33239bcd1e059f8b9c6d48d8f26609
Reviewed-on: https://go-review.googlesource.com/c/go/+/587820
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
This commit is contained in:
Robert Griesemer 2024-05-23 14:40:22 -07:00 committed by Robert Griesemer
parent 13e3068b9c
commit 2fe2e4d593
2 changed files with 10 additions and 2 deletions

View file

@ -184,6 +184,10 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
// Thus, for untyped arguments we only need to look at parameter types
// that are single type parameters.
// Also, untyped nils don't have a default type and can be ignored.
// Finally, it's not possible to have an alias type denoting a type
// parameter declared by the current function and use it in the same
// function signature; hence we don't need to Unalias before the
// .(*TypeParam) type assertion above.
untyped = append(untyped, i)
}
}
@ -306,7 +310,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
// maximum untyped type for each of those parameters, if possible.
var maxUntyped map[*TypeParam]Type // lazily allocated (we may not need it)
for _, index := range untyped {
tpar := params.At(index).typ.(*TypeParam) // is type parameter by construction of untyped
tpar := params.At(index).typ.(*TypeParam) // is type parameter (no alias) by construction of untyped
if u.at(tpar) == nil {
arg := args[index] // arg corresponding to tpar
if maxUntyped == nil {

View file

@ -187,6 +187,10 @@ func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type,
// Thus, for untyped arguments we only need to look at parameter types
// that are single type parameters.
// Also, untyped nils don't have a default type and can be ignored.
// Finally, it's not possible to have an alias type denoting a type
// parameter declared by the current function and use it in the same
// function signature; hence we don't need to Unalias before the
// .(*TypeParam) type assertion above.
untyped = append(untyped, i)
}
}
@ -309,7 +313,7 @@ func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type,
// maximum untyped type for each of those parameters, if possible.
var maxUntyped map[*TypeParam]Type // lazily allocated (we may not need it)
for _, index := range untyped {
tpar := params.At(index).typ.(*TypeParam) // is type parameter by construction of untyped
tpar := params.At(index).typ.(*TypeParam) // is type parameter (no alias) by construction of untyped
if u.at(tpar) == nil {
arg := args[index] // arg corresponding to tpar
if maxUntyped == nil {