Skip to content

Commit 722dd87

Browse files
committed
Add test
1 parent e51f85d commit 722dd87

File tree

1 file changed

+150
-0
lines changed

1 file changed

+150
-0
lines changed

tests/neg/i4368.scala

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
object Test1 {
2+
trait X {
3+
type A = B
4+
type B
5+
}
6+
trait Y {
7+
type A
8+
type B = A
9+
}
10+
trait Z extends X with Y // error: cyclic
11+
}
12+
13+
object Test2 {
14+
trait W {
15+
type A
16+
type B
17+
}
18+
trait X { z: W =>
19+
type A = z.B
20+
type B
21+
}
22+
trait Y { z: W =>
23+
type A
24+
type B = z.A
25+
}
26+
trait Z extends X with Y // error: cyclic
27+
}
28+
29+
object Test3 {
30+
trait W {
31+
type A
32+
type B
33+
}
34+
trait X { z: W =>
35+
type A = z.B
36+
type B
37+
}
38+
trait Y { z: W =>
39+
type A
40+
type B = z.A
41+
}
42+
43+
object App {
44+
type Z = X with Y
45+
val z: Z = z
46+
val a: z.A = a // error: too deep
47+
}
48+
}
49+
50+
object Test4 {
51+
trait X[F[_]] {
52+
protected type A = F[B]
53+
protected type B
54+
}
55+
trait Y[F[_]] {
56+
protected type A
57+
protected type B = F[A]
58+
}
59+
60+
trait Fix[F[_]] extends X[F] with Y[F] {
61+
type Result = A // error: too deep
62+
}
63+
}
64+
65+
object Test5 {
66+
trait X {
67+
type A = B
68+
type B
69+
}
70+
trait Y {
71+
type A
72+
type B = A
73+
}
74+
75+
object App {
76+
type Z = X & Y
77+
val z: Z = z
78+
val a: z.A = a // error: too deep
79+
}
80+
}
81+
82+
object Test6 {
83+
trait W { type T <: W; val t: T }
84+
trait X {
85+
type A = b.T
86+
val a : A = b.t
87+
type B <: W
88+
val b : B
89+
}
90+
trait Y {
91+
type A <: W
92+
val a : A
93+
type B = a.T
94+
val b = a.t
95+
}
96+
trait Z extends X with Y // error: cyclic
97+
}
98+
99+
object Test7 {
100+
class Fix[F[_]] {
101+
class Foo { type R >: F[T] <: F[T] }
102+
type T = F[Foo#R]
103+
}
104+
105+
object App {
106+
type Nat = Fix[Option]#T // error: too deep
107+
}
108+
}
109+
/*
110+
object Test8 {
111+
112+
class A {
113+
type T = B#U // error: cyclic
114+
}
115+
116+
class B {
117+
type U = A#T
118+
}
119+
}
120+
*/
121+
object Test9 {
122+
trait W {
123+
type A
124+
}
125+
trait X extends W {
126+
type A = B
127+
type B
128+
}
129+
trait Y extends W {
130+
type A
131+
type B = A
132+
}
133+
134+
trait Foo[X <: W, Y <: W] {
135+
type Z = X & Y
136+
val z: Z
137+
val a: z.A
138+
}
139+
140+
trait Boo {
141+
val f: Foo[X, Y]
142+
}
143+
144+
trait Baz extends Boo {
145+
val a = f.a // error: member search too deep
146+
// this should be a cyclic error, but it goes undetected
147+
// scalac reports a volatility error, but the dotty equivalent (checkRealizable)
148+
// is checked too late.
149+
}
150+
}

0 commit comments

Comments
 (0)