Optype should never return a defined type.
Change-Id: I37b29e0c958e127e75e834e71d6392ea80827773
Reviewed-on: https://go-review.googlesource.com/c/go/+/357694
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
return P{E{"foo": x}}
return P{{"foo": x}, {}}
}
+
+// This is a degenerate case with a singleton type set, but we can create
+// composite literals even if the structural type is a defined type.
+type MyInts []int
+
+func _[P MyInts]() P {
+ return P{}
+}
// See also issue #39680.
if u := t.structuralType(); u != nil {
assert(u != typ) // "naked" type parameters cannot be embedded
- return u
+ return under(u) // optype should always return an underlying type
}
return theTop
}
return P{E{"foo": x}}
return P{{"foo": x}, {}}
}
+
+// This is a degenerate case with a singleton type set, but we can create
+// composite literals even if the structural type is a defined type.
+type MyInts []int
+
+func _[P MyInts]() P {
+ return P{}
+}
// See also issue #39680.
if u := t.structuralType(); u != nil {
assert(u != typ) // "naked" type parameters cannot be embedded
- return u
+ return under(u) // optype should always return an underlying type
}
return theTop
}