Aladdin - Scala Bugtracking
[#1056] project: compiler priority: high category: bug
submitter assigned to status date submitted
Adriaan Adriaan fixed 2007-04-18 13:35:35.0
subject compiler crash in typedFunction when function type is an alias
code
object Test {
  type T = PartialFunction[String,String]
  def g(h: T) = ()
  g({case s: String => s})
}
what happened
Exception in thread "main" java.lang.UnsupportedOperationException: Nil.init
        at scala.List.init(List.scala:506)
        at scala.tools.nsc.typechecker.Typers$Typer.decompose$1(Typers.scala:1320)
        at scala.tools.nsc.typechecker.Typers$Typer.typedFunction(Typers.scala:1324)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:2447)
what expected
[back to overview]
Changes of this bug report
Adriaan  edited on  2007-04-18 13:51:15.0
this bug raised a tricky issue with alias types: whenever you see `tp.symbol.isXXXX' and then act on tp based on that predicate, you're on thin ice, as `symbol' (and `prefix') automatically normalize, but the other inspectors don't. In other words, even if `tp.normalize.sym.isXXX' is true, `tp.sym.isXXX' may be false (if sym were a public method to access the non-normalized symbol)... In retrospect, I think `tp.symbol.isXXX' or (worse) `tp.symbol==XXX' should be replaced by `val tp = tp0.asXXX'. A type's symbol should never be inspected directly.