Aladdin - Scala Bugtracking
[#229] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Stephane Martin fixed 2003-11-18 14:01:38.0
subject error overriding method
code
class Test extends java.util.ArrayList {
  override def add(index: Int, element: java.lang.Object) = {}
}
what happened
Test.scala:2: error overriding method listIterator in class java.util.AbstractList;
 method listIterator in trait java.util.List needs `override' modifier
class Test extends java.util.ArrayList {
                   ^
Test.scala:2: class Test needs to be abstract, since method listIterator in trait java.util.List is not defined
\

class Test extends java.util.ArrayList {
      ^
Test.scala:3: method add overrides nothing
  override def add(index: Int, element: java.lang.Object) = {}
               ^
three errors found
what expected No error (same example works fine in Java)
[back to overview]
Changes of this bug report
Martin  edited on  2004-01-08 15:43:19.0
Philippe  edited on  2004-09-24 13:35:20.0
I reopend this bug because on lampsun1 this example produces the following error:
/home/paltherr/work/scala-cvs/test/files/pos/bug229.scala:2: Accidental override:
method add: (scala.Int,java.lang.Object)scala.Unit has same type after erasure as
method add: (scala.Int,scala.Any)scala.Unit which is inherited from class ArrayList
  override def add(index: int, element: java.lang.Object): unit = {}
               ^
one error found
There is no error on the lamppcs. This difference is probably due to the fact that the pcs and the sun run two different versions of java: 1.4.2_05-b04 for the pcs and 1.4.1_02-b06 for the sun.
Martin  edited on  2006-03-30 19:01:09.0