Skip to content

Commit 34cee41

Browse files
liufengyunmichelou
authored andcommitted
Fix scala#4042: add test
1 parent a2ef665 commit 34cee41

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/init/neg/i4042.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
object App {
2+
def coerce[U, V](u: U): V = {
3+
trait X { type R >: U }
4+
trait Y { type R = V }
5+
6+
class T[A <: X](val a: A)(val value: a.R)
7+
8+
object O { val x : Y & X = x } // error
9+
10+
val a = new T[Y & X](O.x)(u)
11+
a.value
12+
}
13+
14+
def main(args: Array[String]): Unit = {
15+
val x: Int = coerce[String, Int]("a")
16+
println(x + 1)
17+
}
18+
}

0 commit comments

Comments
 (0)