Skip to content

Commit 816b603

Browse files
griesemergopherbot
authored andcommitted
go/types, types2: add missing Unalias calls (clarification)
This change adds an Unalias call in applyTypeFunc and arrayPtrDeref. At the moment this doesn't change anything or fix any bugs because of the way these two functions are invoked, but that could change in the future. Also, manually reviewed all type assertions to Type types. Excluding assertions to type parameters, no obvious issues were found except for #67540 for which a separate fix is pending. There are potential issues with assertions type parameters which will be addressed in a follow-up CL. For #67547. Change-Id: I312268dc5e104f95b68f115f00aec3ec4c82e41f Reviewed-on: https://go-review.googlesource.com/c/go/+/587156 Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Robert Griesemer <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent 7164fad commit 816b603

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ func hasVarSize(t Type, seen map[*Named]bool) (varSized bool) {
960960
// applyTypeFunc returns nil.
961961
// If x is not a type parameter, the result is f(x).
962962
func (check *Checker) applyTypeFunc(f func(Type) Type, x *operand, id builtinId) Type {
963-
if tp, _ := x.typ.(*TypeParam); tp != nil {
963+
if tp, _ := Unalias(x.typ).(*TypeParam); tp != nil {
964964
// Test if t satisfies the requirements for the argument
965965
// type and collect possible result types at the same time.
966966
var terms []*Term
@@ -1026,7 +1026,7 @@ func makeSig(res Type, args ...Type) *Signature {
10261026
// arrayPtrDeref returns A if typ is of the form *A and A is an array;
10271027
// otherwise it returns typ.
10281028
func arrayPtrDeref(typ Type) Type {
1029-
if p, ok := typ.(*Pointer); ok {
1029+
if p, ok := Unalias(typ).(*Pointer); ok {
10301030
if a, _ := under(p.base).(*Array); a != nil {
10311031
return a
10321032
}

src/go/types/builtins.go

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

0 commit comments

Comments
 (0)