Skip to content

Static vars generate wrong field #2375

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
odersky opened this issue May 5, 2017 · 1 comment
Closed

Static vars generate wrong field #2375

odersky opened this issue May 5, 2017 · 1 comment

Comments

@odersky
Copy link
Contributor

odersky commented May 5, 2017

If we look at the bytecode produced from run/statics.scala, we see:

Users/odersky/workspace/dotty/tests/run> javap -cp /classes -private Foo
Compiled from "statics.scala"
public class Foo {
  public static final long OFFSET$0;
  public long bitmap$0;
  public Foo$Bar$ Bar$lzy1;
  public static int mutable;
  public static int field;
  private static int mutable$$local;
  public Foo();
  private static {};
  public final Foo$Bar$ Bar();
  public static int method();
  public static void mutable_$eq(int);
  public static int accessor();
}

Note that both mutable and mutable$$local are fields. mutable should be an accessor method instead. This bug prevents us from dropping $$local suffixes in semantic names.

@DarkDimius
Copy link
Contributor

Investigating.

DarkDimius added a commit to dotty-staging/dotty that referenced this issue May 5, 2017
They are not transformed by Getters phase,
they keep the original name and never renamed.
DarkDimius added a commit to dotty-staging/dotty that referenced this issue May 5, 2017
They are not transformed by Getters phase,
they keep the original name and never renamed.
DarkDimius added a commit to dotty-staging/dotty that referenced this issue May 5, 2017
They are not transformed by Getters phase,
they keep the original name and never renamed.
@odersky odersky closed this as completed in e4d317f May 6, 2017
odersky added a commit that referenced this issue May 6, 2017
Fix #2375: Memoize should not generate static fields.
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