When inheriting from a Java class with public members, using scala's override
modifier raises compilation error like so:
Error:(67, 22) overriding variable userId in class Logon of type String;
value userId has incompatible type
override val userId = s.user
^
The java class looks something along the following lines:
public class Logon {
public String userId = "";
}
and the scala code:
class MyLogon extends Logon {
override val userId : String = "abc"
}
Removing the modifier results in:
Error:(72, 7) overriding variable userId in class Logon of type String;
value userId needs `override' modifier
val userId: String = s.user
^
Why is this? Is it a bug? There are related questions e.g. 16607517 but these seem to be changing the visibility of the fields; that's not the case here - they're all public.
Believe this is with scalac-2.10.4.