|
[#1062] |
project: compiler |
priority: low |
category: bug |
|
submitter |
assigned to |
status |
date submitted |
|
Lex |
Martin |
fixed |
2007-04-20 23:49:33.0 |
subject |
field versus method in Java code |
code |
// in Java:
class MethVsField
{
int three = 3;
int three()
{
return 3;
}
}
// in Scala:
object Test extends Application {
println((new MethVsField).three)
} |
what happened |
methvsfield.scala:2: error: ambiguous reference to overloaded definition,
both method three in class MethVsField of type ()Int
and variable three in class MethVsField of type Int
match expected type Any
println((new MethVsField).three)
|
what expected |
The should access the field. First, otherwise there is no other way to access such a Java field. Second, if the expression makes sense exactly as it is written, then there is no need to entertain the idea of adding () to it. |
[back to overview] |