Aladdin - Scala Bugtracking
[#1059] project: compiler priority: low category: missing feature
submitter assigned to status date submitted
Adriaan Martin fixed 2007-04-20 08:39:28.0
subject [a|i]sInstanceOf[T] where T is erased should emit unchecked warning
code
class A[t]{ 
  def unsafe(a: Any):boolean = a.isInstanceOf[t]
  def unsafe2[s](a: Any):boolean = a.isInstanceOf[s]
  def unsafe3[s](a: Any):s = a.asInstanceOf[s]
}
what happened
no warning (both in 2.4.0 and trunk)
what expected unchecked warnings about the .sInstanceOf's
[back to overview]
Changes of this bug report
Lex  edited on  2007-04-20 15:34:00.0
This is very tricky. The two cases should not necessarily have the same behavior. asInstanceOf is often used in cases where there is no way to fix the problem. An example I run into is wrapping a Java library where everything is of type Object; you sometimes have to cast to a type parameter even though it will be an unchecked cast. isInstanceOf warnings I am more sympathetic about; maybe that one should even be an error.
Martin  edited on  2007-07-19 21:04:03.0
isInstanceOf now generates unchecked warnings but asInstanceOf does not.