blob: a76f52b74878e1a5e5edd2237e3ca367729dd7ab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
object Test {
class A; class B
def main(args: Array[String]): Unit = {
def noExpectedType(): Unit = {
a().asInstanceOf[B] // cast elided!
}
def withExpectedType(): B = {
a().asInstanceOf[B]
}
def test(a: => Any) = try {
a
sys.error("no CCE!")
} catch {case _: ClassCastException => }
test(noExpectedType())
test(withExpectedType())
}
def a(): Object = new A
}
|