Skip to content

Commit 3367591

Browse files
committed
Test case #4906
1 parent 4144cad commit 3367591

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/pos/i4906.scala

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
}

0 commit comments

Comments
 (0)