Skip to content

Missing check when trying to override a Java field #9115

@smarter

Description

@smarter
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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions