aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/infer.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-05-27 22:09:58 -0700
committerRobert Griesemer <gri@golang.org>2021-06-02 23:19:27 +0000
commit3c1d502a19dcdaaf0f7ddf58ccad9953fe5d92d1 (patch)
treea1dc7779abe65bab182f3d2464e0c1cb6b0e9d27 /src/cmd/compile/internal/types2/infer.go
parent848b58e47357965dc5a61fb0ae5535da717e2633 (diff)
downloadgo-3c1d502a19dcdaaf0f7ddf58ccad9953fe5d92d1.tar.gz
go-3c1d502a19dcdaaf0f7ddf58ccad9953fe5d92d1.zip
[dev.typeparams] cmd/compile/internal/types2: eliminate need for unpack and asUnion functions
Change-Id: Iaa75b091d52f44939330e5945305aea323ba58f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/323355 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/infer.go')
-rw-r--r--src/cmd/compile/internal/types2/infer.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go
index 73ea8330d4..63cd63aacc 100644
--- a/src/cmd/compile/internal/types2/infer.go
+++ b/src/cmd/compile/internal/types2/infer.go
@@ -328,7 +328,7 @@ func (w *tpWalker) isParameterized(typ Type) (res bool) {
return true
}
}
- return w.isParameterizedList(unpack(t.allTypes))
+ return w.isParameterized(t.allTypes)
}
return t.iterate(func(t *Interface) bool {
@@ -477,11 +477,14 @@ func (check *Checker) inferB(tparams []*TypeName, targs []Type, report bool) (ty
func (check *Checker) structuralType(constraint Type) Type {
if iface, _ := under(constraint).(*Interface); iface != nil {
check.completeInterface(nopos, iface)
- types := unpack(iface.allTypes)
- if len(types) == 1 {
- return types[0]
+ if u, _ := iface.allTypes.(*Union); u != nil {
+ if u.NumTerms() == 1 {
+ // TODO(gri) do we need to respect tilde?
+ return u.types[0]
+ }
+ return nil
}
- return nil
+ return iface.allTypes
}
- return constraint
+ return nil
}