summaryrefslogtreecommitdiff
path: root/test/files/run/t7763.scala
blob: 638077e64ade2dbdeb224d3901c71c05e248b341 (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]) {
    def noExpectedType() {
      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
}