aboutsummaryrefslogtreecommitdiff
path: root/src/go/types/infer.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/types/infer.go')
-rw-r--r--src/go/types/infer.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/go/types/infer.go b/src/go/types/infer.go
index f3f69e01b6..6e70a103e7 100644
--- a/src/go/types/infer.go
+++ b/src/go/types/infer.go
@@ -303,7 +303,7 @@ func (w *tpWalker) isParameterized(typ Type) (res bool) {
}
case *Union:
- return w.isParameterizedList(t.types)
+ return w.isParameterizedTermList(t.terms)
case *Signature:
// t.tparams may not be nil if we are looking at a signature
@@ -331,7 +331,7 @@ func (w *tpWalker) isParameterized(typ Type) (res bool) {
return w.isParameterized(t.elem)
case *Named:
- return w.isParameterizedList(t.targs)
+ return w.isParameterizedTypeList(t.targs)
case *TypeParam:
// t must be one of w.tparams
@@ -344,7 +344,7 @@ func (w *tpWalker) isParameterized(typ Type) (res bool) {
return false
}
-func (w *tpWalker) isParameterizedList(list []Type) bool {
+func (w *tpWalker) isParameterizedTypeList(list []Type) bool {
for _, t := range list {
if w.isParameterized(t) {
return true
@@ -353,6 +353,15 @@ func (w *tpWalker) isParameterizedList(list []Type) bool {
return false
}
+func (w *tpWalker) isParameterizedTermList(list []*term) bool {
+ for _, t := range list {
+ if w.isParameterized(t.typ) {
+ return true
+ }
+ }
+ return false
+}
+
// inferB returns the list of actual type arguments inferred from the type parameters'
// bounds and an initial set of type arguments. If type inference is impossible because
// unification fails, an error is reported if report is set to true, the resulting types
@@ -461,7 +470,8 @@ func (check *Checker) structuralType(constraint Type) Type {
if u, _ := types.(*Union); u != nil {
if u.NumTerms() == 1 {
// TODO(gri) do we need to respect tilde?
- return u.types[0]
+ t, _ := u.Term(0)
+ return t
}
return nil
}