[#395] | project: compiler | priority: low | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Michel | Martin | fixed | 2005-01-28 09:42:03.0 | |
subject | Phony overloading of static fields coming from Java classes | |||
code |
// File Statics.java package test; class Superclass { public static final int x = 42; } class Subclass extends Superclass { public static final double x = 42.0; } class JavaMain { public static void main(String[] args) { System.out.println(Subclass.x); } } // File Main.scala package test; object Main { def main(args: Array[String]): Unit = { System.out.println(Subclass.x); } } |
|||
what happened | scalac complains with the following error:Main.scala:5: ambiguous reference to overloaded definition, both value x: scala.Double(42.0) and value x: scala.Int(42) match expected type <any type> System.out.println(Subclass.x); ^ one error found |
|||
what expected | No error, as there is really no overloading here, at least from Java's point of view (class JavaMain works as expected). This doesn't seem to be a huge problem, as it is possible to work around it by giving an explicit type, but I think that either the specification or the implementation should be changed. |
|||
[back to overview] |
Martin edited on 2006-03-30 18:26:56.0 |
Fixed in version 2 |