aboutsummaryrefslogblamecommitdiff
path: root/tests/run/t7763.scala
blob: a76f52b74878e1a5e5edd2237e3ca367729dd7ab (plain) (tree)



















                                            
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
}