Skip to content

Backend generates useless companion class for inner objects #2680

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 Jun 4, 2017 · 4 comments
Closed

Backend generates useless companion class for inner objects #2680

smarter opened this issue Jun 4, 2017 · 4 comments

Comments

@smarter
Copy link
Member

smarter commented Jun 4, 2017

The following code:

object Outer {
  object Inner
}

generates the following files with scalac:

Outer.class  Outer$.class  Outer$Inner$.class

and the following files with Dotty:

Outer.class  Outer.hasTasty  Outer$.class  Outer$Inner.class  Outer$Inner$.class

The Outer.hasTasty is expected but the Outer$Inner.class isn't, it doesn't seem to contain much:

% cfr 'Outer$Inner.class'
/*
 * Decompiled with CFR 0_120.
 */
public final class Outer$Inner {
}

Could we avoid generating these companions? On case-insenstive filesystems they can be harmful: #2673 (comment)

@smarter
Copy link
Member Author

smarter commented Jun 4, 2017

DarkDimius added exp:novice and removed exp:expert labels 9 minutes ago

I think for something to be novice-level it needs to be obvious how to fix, or you need to give some instructions on how someone could fix it ;).

@abeln
Copy link
Contributor

abeln commented Jun 4, 2017

I'd be happy to take a look at this if given some pointers.

@DarkDimius
Copy link
Contributor

@abeln, backend has a single entry-point to decide where to output files: method getFileForClassfile. I'd intercept this method in debugger and see when is it called for the generated class and why.

@smarter
Copy link
Member Author

smarter commented Jun 5, 2017

Also we have some docs on the backend you might find helpful: http://dotty.epfl.ch/docs/contributing/backend.html and http://dotty.epfl.ch/docs/internals/backend.html

DarkDimius added a commit that referenced this issue Jun 7, 2017
Fix #2680: Backend generates useless companion class for inner objects
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

3 participants