//
// To avoid needing to represent type unions in types1 (since we
// don't have any uses for that today anyway), we simply fold them
- // to "any". As a consistency check, we still read the union terms
- // to make sure this substitution is safe.
-
- pure := false
- for i, n := 0, r.Len(); i < n; i++ {
- _ = r.Bool() // tilde
- term := r.typ()
- if term.IsEmptyInterface() {
- pure = true
+ // to "any".
+
+ // TODO(mdempsky): Restore consistency check to make sure folding to
+ // "any" is safe. This is unfortunately tricky, because a pure
+ // interface can reference impure interfaces too, including
+ // cyclically (#60117).
+ if false {
+ pure := false
+ for i, n := 0, r.Len(); i < n; i++ {
+ _ = r.Bool() // tilde
+ term := r.typ()
+ if term.IsEmptyInterface() {
+ pure = true
+ }
+ }
+ if !pure {
+ base.Fatalf("impure type set used in value type")
}
- }
- if !pure {
- base.Fatalf("impure type set used in value type")
}
return types.Types[types.TINTER]
package p
type Any any
+type IntOrBool interface{ int | bool }
-type I interface{ Any | int }
+type I interface{ Any | IntOrBool }
var (
X I = 42
Y I = "xxx"
Z I = true
)
+
+type A interface{ *B | int }
+type B interface{ A | any }