Aladdin - Scala Bugtracking
[#191] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Matthias Martin fixed 2003-10-07 12:50:19.0
subject Class overriding
code
class A {
  private class C {
    def print = Console.println("A.C");
  }
  def foo(c: C) = c.print;
}
class B extends A {
  class C {
    def show = Console.println("B.C");
  }
  foo(new C);
}
object Main with Executable {
  val b = new B;
}
what happened
The code above compiles; i.e. it seems like the compiler allows to override private classes. Since A.C and B.C a\
re unrelated the generated code is not well-formed. This bug is probably related to #182. Here's the output:
Exception in thread "main" java.lang.ExceptionInInitializerError
        at Main.main(T2.scala)
Caused by: java.lang.ClassCastException
        at B$class.(T2.scala:11)
        at Main$.(T2.scala:14)
        at Main$.(T2.scala)
        ... 1 more
what expected Compiler error stating that foo is not applicable to B.C.
[back to overview]
Changes of this bug report
Martin  edited on  2003-10-08 20:36:53.0
here's the new error message -- it makes sense only if -uniqid is set.
test/neg/bug191.scala:11: type mismatch;
 found   : B#0.this.C#1
 required: B#0.this.C#2