Skip to content
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

IMPORT intermittently generates incorrect multi-level packages when defined from a String #35

Open
julianpeeters opened this issue May 18, 2016 · 4 comments

Comments

@julianpeeters
Copy link
Contributor

Defining in IMPORT with a Symbol seems to have solved my issue, but I thought I should report issue I had when generating imports from Strings.

For example "org.apache.avro.Schema" variously becomes "org.Schema", or "org.apache.org.apache.avro.Schema", etc, until I predefine the Symbol with RootClass.newClass("org.apache.avro.Schema").

I tried to make a MRE, but it seems that the project needs to be large and slow for this issue to arrise(?).

@julianpeeters
Copy link
Contributor Author

Tracked the bug to here (id.symbol.fullName is already corrupted), but not further because I don't follow how symbols are generated from the String arguments of IMPORT.

case id: Ident if id.symbol != NoSymbol => id.symbol.fullName

@eed3si9n
Copy link
Owner

I wonder if there's some race condition around

private def getModuleOrClass(path: Name, len: Int): Symbol =
symbolCache.getOrElseUpdate(path, {
val point = path lastPos('.', len - 1)
val owner =
if (point > 0) getModuleOrClass(path.toTermName, point).moduleClass
else RootClass
val name = path subName (point + 1, len)
if (path.isTypeName) owner.newClass(name.toTypeName)
else owner.newModule(name.toTermName)
})

@er1c
Copy link

er1c commented Nov 12, 2016

This is definitely a mind-phrack while debugging, confirmed the Symbol references fixes the problem.

er1c added a commit to er1c/scala-java-locales that referenced this issue Nov 20, 2016
er1c added a commit to er1c/scala-java-locales that referenced this issue Nov 21, 2016
er1c added a commit to er1c/scala-java-locales that referenced this issue Nov 21, 2016
er1c added a commit to er1c/scala-java-locales that referenced this issue Nov 29, 2016
er1c added a commit to er1c/scala-java-locales that referenced this issue Nov 30, 2016
Romastyi added a commit to Romastyi/sbt-play-boilerplate that referenced this issue Jan 11, 2018
Romastyi added a commit to Romastyi/sbt-play-boilerplate that referenced this issue Jan 23, 2018
@franzhcs
Copy link

Just quickly to mention that I have hit this problem today (on 0.4.3).

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

4 participants