Skip to content

Commit 4028c5f

Browse files
griesemerpull[bot]
authored andcommitted
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 <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Robert Griesemer <[email protected]>
1 parent 5618059 commit 4028c5f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/cmd/compile/internal/types2/infer.go

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

src/go/types/infer.go

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)