Skip to content

Scoped private object methods still emit static forwards #10842

@dwijnand

Description

@dwijnand

Minimized code

package p

object A {
  private[p] def m() = 1
}

Output

$ echo 'package p; object A { private[p] def m() = 1 }' > A.scala && scalac3 A.scala && javap -p p.A p.A$
Compiled from "A.scala"
public final class p.A {
  public static int m();
}
Compiled from "A.scala"
public final class p.A$ implements java.io.Serializable {
  public static final p.A$ MODULE$;
  private p.A$();
  public static {};
  private java.lang.Object writeReplace();
  public int m();
}

Expectation

$ echo 'package p; object A { private[p] def m() = 1 }' > A.scala && scalac A.scala && javap -p p.A p.A$
Compiled from "A.scala"
public final class p.A {
}
Compiled from "A.scala"
public final class p.A$ {
  public static final p.A$ MODULE$;
  public static {};
  public int m();
  private p.A$();
}

I'm not sure about the criticality of this. It's within the subset of java interop, but it's also related to what/how bytecode is emitted...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions