Aladdin - Scala Bugtracking
[#338] project: compiler priority: low category: bug
submitter assigned to status date submitted
Philippe Martin fixed 2004-06-04 13:46:55.0
subject Analyzer inserts undeclared type variables
code
class Foo[X];
object Test {
  def apply[X](): Foo[X] = null;
  def main(args: Array[String]): Unit = {
    Test().toString();             // -> Test.apply[scala.All]() ...  ok
    Test() match { case _ => () }  // -> Test.apply[X]() ...  KO what's this X?
    List() match { case _ => () }  // -> List.apply[A]() ...  KO what's this A?
  }
}
what happened
Crash in LambdaLift
Exception in thread "main" java.lang.AssertionError: type X in method apply
	at scalac.transformer.LambdaLift$FreeVars.markFree(LambdaLift.java:178)
However, there is already a problem after the analyzer as can be seen in the following tree.
[[syntax trees at refcheck (after analyze)]]
// Scala source: tmp/test.scala
class Foo[X] extends java.lang.Object() with scala.ScalaObject();
final object Test extends java.lang.Object() with scala.ScalaObject() {
  final def apply[X](): Foo[X] = null;
  final def main(args: scala.Array[scala.Predef.String]): scala.Unit = {
    Test.apply[scala.All]().toString();
    Test.apply[X]().match({
        case _ => ()
      });
    scala.List.apply[A]().match({
        case _ => ()
      })
  }
};
The expressions Test() match and List match are translated into trees that contain the\ type variables X and A which are never declared.
what expected no error
[back to overview]
Changes of this bug report
Philippe  edited on  2004-06-04 15:47:55.0
Same bug as 339
Martin  edited on  2004-07-02 14:17:11.0