Skip to content

final val in trait should not be encoded as abstract method #8602

Closed
@ohze

Description

@ohze

minimized code

trait Scala {
  final val x = 1
}
class Java implements Scala { }

Compilation output

[error] /Users/thanhbv/ohze/dotty-example/src/main/java/Java.java:1:1: Java is not abstract and does not override abstract method x() in Scala
[error] (Compile / compileIncremental) javac returned non-zero exit code

expectation

compile successfully as in scala 2

inspect

dotty-example % javap target/scala-2.13/classes/Scala.class 
Compiled from "Scala.scala"
public interface Scala {
  public static int x$(Scala);
  public int x();
  public static void $init$(Scala);
}
dotty-example % javap target/scala-0.23/classes/Scala.class
Compiled from "Scala.scala"
public interface Scala {
  public void $init$();
  public abstract int x();
  public int initial$x();
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions