Aladdin - Scala Bugtracking
[#402] project: compiler priority: low category: bug
submitter assigned to status date submitted
Michel Martin won't fix 2005-02-21 16:38:49.0
subject isInstanceOf permitted on value types
code
object Main {
  def main(args: Array[String]): Unit = {
    System.out.println((0.5).isInstanceOf[Int]);
  }
}
what happened
The compiler accepted the program.
what expected A compile-time error, according to my recollection of our discussion some time ago. The reference should also be changed (chap. 12) to say that isInstanceOf is defined in AnyRef, not in Any as it is now.
[back to overview]
Changes of this bug report
Martin  edited on  2006-10-30 16:51:28.0
Since asInstanceOf works for all types, I think isInstanceOf should do the same. Also, it is occasionally useful to find out whether an Any is an Int, as in:
    val x: Any = 2
    System.out.println(x.isInstanceOf[Int])