Skip to content

Missing check when trying to override a Java field #9115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
smarter opened this issue Jun 7, 2020 · 1 comment
Closed

Missing check when trying to override a Java field #9115

smarter opened this issue Jun 7, 2020 · 1 comment

Comments

@smarter
Copy link
Member

smarter commented Jun 7, 2020

public class A {
  public String foo = "A";
}
class B extends A {
  override val foo: String = "B"
}

This should not compile, because Java fields are in fact not overridable. Scala 2 realizes that and emits a (confusing) error at refchecks:

try/B.scala:2: error: incompatible type in overriding
var foo: String (defined in class JA);
 found   : String
 required: String
  override val foo: String = "B"
               ^

but dotty doesn't.

@smarter
Copy link
Member Author

smarter commented Jun 7, 2020

@bishabosha I'm not planning to work on this for now.

@odersky odersky self-assigned this Jun 8, 2020
@odersky odersky closed this as completed in 945b31e Jun 8, 2020
odersky added a commit that referenced this issue Jun 8, 2020
Fix #9115: Make Java-defined fields effectively final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants