Skip to content

Dotty creates unnecessary fields in anonymous classes, leading to memory leaks #2883

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
smarter opened this issue Jul 17, 2017 · 0 comments
Closed

Comments

@smarter
Copy link
Member

smarter commented Jul 17, 2017

Given:

class Wrapper(val value: Int)

abstract class Foo(val x: Int)

class Test {
  def foo(wrapper: Wrapper): Unit = {
    new Foo(wrapper.value) {}
  }
}

Dotty generates:

private static final class Test$$anon$1
extends Foo {
    private final Wrapper wrapper$1;

    public Test$$anon$1(Wrapper wrapper$2) {
        this.wrapper$1 = wrapper$2;
        super(wrapper$2.value());
    }
}

But Scala 2.12 does:

public final class Test$$anon$1
extends Foo {
    public Test$$anon$1(Test $outer, Wrapper wrapper$1) {
        super(wrapper$1.value());
    }
}

This is similar to #2869

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

1 participant