File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ object Test {
2+ trait A
3+ trait TestConstructor1 { type F [_ <: A ] }
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+ }
12+
13+ val v1 : TestConstructor1 => Unit = { f =>
14+ type P [a <: A ] = f.F [a] // OK
15+ }
16+
17+ val v2 : TestConstructor2 [A ] => Unit = { f =>
18+ type P [a <: A ] = f.F [a] // Error! Type argument a does not conform to upper bound D
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 = ??? // ok
26+ val v4 : (f : TestConstructor2 [A ]) => (g : f.TestConstructor3 [A ]) => Unit = {f => ??? }
27+ val v5 : (f : TestConstructor2 [A ]) => (g : f.TestConstructor3 [A ]) => Unit = {(f : TestConstructor2 [A ]) => ??? }
28+ // }
29+ def f3 (f : TestConstructor2 [A ], g : f.TestConstructor3 [A ]): Unit = {
30+ type P [a <: A ] = f.F [a] // Error! Type argument a does not conform to upper bound D
31+ type Q [a <: A ] = g.G [a]
32+ // type R[a <: A] = (f.F & g.G)[a] // compiler error
33+ type R [a <: A ] = ([X <: A ] =>> f.F [X ] & g.G [X ])[a]
34+ type S [a <: A ] = f.G [a] & g.H [a]
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments