}
}
+ case *Union:
+ for _, t := range t.terms {
+ if check.validType(t.typ, path) == invalid {
+ return invalid
+ }
+ }
+
case *Interface:
for _, etyp := range t.embeddeds {
if check.validType(etyp, path) == invalid {
// Test case from issue.
-type Nat interface {
+type Nat /* ERROR cycle */ interface {
Zero|Succ
}
--- /dev/null
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type N /* ERROR cycle */ interface {
+ int | N
+}
+
+type A /* ERROR cycle */ interface {
+ int | B
+}
+
+type B interface {
+ int | A
+}
+
+type S /* ERROR cycle */ struct {
+ I // ERROR interface contains type constraints
+}
+
+type I interface {
+ int | S
+}
+
+type P interface {
+ *P // ERROR interface contains type constraints
+}
}
}
+ case *Union:
+ for _, t := range t.terms {
+ if check.validType(t.typ, path) == invalid {
+ return invalid
+ }
+ }
+
case *Interface:
for _, etyp := range t.embeddeds {
if check.validType(etyp, path) == invalid {
// Test case from issue.
-type Nat interface {
+type Nat /* ERROR cycle */ interface {
Zero|Succ
}
type Zero struct{}
type Succ struct{
- Nat // ERROR interface contains type constraints
+ Nat /* ERROR interface contains type constraints */
}
// Struct tests.
--- /dev/null
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type N /* ERROR cycle */ interface {
+ int | N
+}
+
+type A /* ERROR cycle */ interface {
+ int | B
+}
+
+type B interface {
+ int | A
+}
+
+type S /* ERROR cycle */ struct {
+ I // ERROR interface contains type constraints
+}
+
+type I interface {
+ int | S
+}
+
+type P interface {
+ *P // ERROR interface contains type constraints
+}