Skip to content

Non idempotent code generated for inner methods #2738

@nicolasstucki

Description

@nicolasstucki
object Foo {
  def foo[X <: Int](x: X) = {
    def bar = "a"
    bar
  }

  def foo(x: String) = {
    def bar = 2
    bar
  }
}

if we use sbt 'run Foo.scala'; javap -p Foo$ I get:

public final class Foo$ {
  public static final Foo$ MODULE$;
  public static {};
  public Foo$();
  public java.lang.String foo(int);
  public int foo(java.lang.String);
  private java.lang.String bar$1();
  private int bar$2();
}

but if we do dotc Foo.scala; javap -p Foo$ I get:

public final class Foo$ {
  public static final Foo$ MODULE$;
  public static {};
  public Foo$();
  public java.lang.String foo(int);
  public int foo(java.lang.String);
  private java.lang.String bar$2();
  private int bar$1();
}

Note that the names bar$1 and bar$2 are inverted. This is not incorrect but might not be good for the incremental compilation as it can invalidates based on class files that have not really changed.

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