Skip to content

Traits in package have an initial method with an illegal method name #577

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 May 16, 2015 · 3 comments
Closed

Comments

@smarter
Copy link
Member

smarter commented May 16, 2015

package foo {
  trait Bar
}
% javap -c foo/Bar
Compiled from "tp.scala"
public interface foo.Bar {
  public foo.Bar initial$foo.Bar();
    Code:
       0: aload_0
       1: areturn

Note that the method contains a '.' which is not allowed:

java.lang.ClassFormatError: Illegal method name "initial$foo.Bar" in class foo/Bar
@smarter
Copy link
Member Author

smarter commented May 16, 2015

This is because TraitConstructors calls fullName, it could be replaced by fullNameSeparated.

@smarter
Copy link
Member Author

smarter commented May 16, 2015

Note that using fullNameSeparated("$") the method becomes initial$fooBar and not initial$foo$Bar, because of the special case:

if (owner.is(ModuleClass) && sep == "$") sep = "" // duplicate scalac's behavior: don't write a double '$$' for module class members.

@smarter
Copy link
Member Author

smarter commented May 17, 2015

Needef for tests/pending/run/Meter.scala.

odersky added a commit to dotty-staging/dotty that referenced this issue May 19, 2015
DarkDimius added a commit that referenced this issue May 21, 2015
TraitConstructors: Use a valid method name for the initializer (fix #577)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant