1
1
object Test {
2
2
trait A
3
3
trait TestConstructor1 { type F [_ <: A ] }
4
- trait TestConstructor2 [D ] { type F [_ <: D ] }
4
+ trait TestConstructor2 [D ] {
5
+ type F [_ <: D ]
6
+ class G [X <: D ]
7
+ trait TestConstructor3 [E ] {
8
+ type G [_ <: D & E ]
9
+ class H [X <: D & E ]
10
+ }
11
+ }
5
12
6
13
val v1 : TestConstructor1 => Unit = { f =>
7
14
type P [a <: A ] = f.F [a] // OK
@@ -10,4 +17,25 @@ object Test {
10
17
val v2 : TestConstructor2 [A ] => Unit = { f =>
11
18
type P [a <: A ] = f.F [a] // Error! Type argument a does not conform to upper bound D
12
19
}
20
+
21
+ def f2 (f : TestConstructor2 [A ]): Unit = {
22
+ type P [a <: A ] = f.F [a] // Error! Type argument a does not conform to upper bound D
23
+ }
24
+
25
+ // val v3: (f: TestConstructor2[A]) => (g: f.TestConstructor3[A]) => Unit = { f => g =>
26
+ // type P[a <: A] = f.F[a] // Error! Type argument a does not conform to upper bound D
27
+ // // type Q[a <: A] = g.G[a]
28
+ // // type R[a <: A] = (f.F & g.G)[a]
29
+ // // type R[a <: A] = ([X] => f.F[X] & g.G[X])[a]
30
+ // }
31
+ def f3 (f : TestConstructor2 [A ], g : f.TestConstructor3 [A ]): Unit = {
32
+ type P [a <: A ] = f.F [a] // Error! Type argument a does not conform to upper bound D
33
+ type Q [a <: A ] = g.G [a]
34
+ // type R[a <: A] = (f.F & g.G)[a] // compiler error
35
+ type R [a <: A ] = ([X <: A ] => f.F [X ] & g.G [X ])[a]
36
+ type S [a <: A ] = f.G [a] & g.H [a]
37
+ }
38
+ // val v4: (f: TestConstructor2[A]) => (g: f.TestConstructor3[A]) => Unit = {f => ???} // crash
39
+ // val v5: (f: TestConstructor2[A]) => (g: f.TestConstructor3[A]) => Unit = {(f: TestConstructor2[A]) => ???} // crash
40
+ // val v6: (f: TestConstructor2[A]) => (g: f.TestConstructor3[A]) => Unit = {(f: TestConstructor2[A]) => (g: f.TestConstructor3[A]) => ???} // crash
13
41
}
0 commit comments