Skip to content

SI-8900 Don't assert !isDelambdafyFunction, it may not be accurate #4049

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

Merged
merged 1 commit into from
Oct 20, 2014

Conversation

lrytz
Copy link
Member

@lrytz lrytz commented Oct 12, 2014

The implementations of isAnonymousClass, isAnonymousFunction,
isDelambdafyFunction and isDefaultGetter check if a specific substring
(eg "$lambda") exists in the symbol's name.

SI-8900 shows an example where a class ends up with "$lambda" in its
name even though it's not a delambdafy lambda class. In this case the
conflict seems to be introduced by a macro. It is possible that the
compiler itself never introduces such names, but in any case, the
above methods should be implemented more robustly.

This commit is band-aid, it fixes one specific known issue, but there
are many calls to the mentioned methods across the compiler which
are potentially wrong.

@retronym
Copy link
Member

I'd like to figure what the macro was doing to generated the name that tripped this, and add a test case.

@paulp
Copy link
Contributor

paulp commented Oct 15, 2014

If you don't want $lambda to appear in class names, nobody can use any identifiers which begin with lambda.

@retronym
Copy link
Member

Here's a test case. Look, Ma, no macros.

package foo
package lambdaking

class Test {
  def byname(b: => Any) = ???
  def foo: Any = {
    def bar: Any = {
      byname(bar)
    }
  }
}

We could simply tighten up those name based checks to look only at initName. (Or alternatively, nme.unexpandedName(name).)

We could also switch over to using flags or symbol annotations for these, although if we do we have to think/test carefully separate compilation scenarios.

No doubt calling your package or function anonFunMeister or anonCoward could also be exploited somehow.

The implementations of isAnonymousClass, isAnonymousFunction,
isDelambdafyFunction and isDefaultGetter check if a specific substring
(eg "$lambda") exists in the symbol's name.

SI-8900 shows an example where a class ends up with "$lambda" in its
name even though it's not a delambdafy lambda class. In this case the
conflict seems to be introduced by a macro. It is possible that the
compiler itself never introduces such names, but in any case, the
above methods should be implemented more robustly.

This commit is band-aid, it fixes one specific known issue, but there
are many calls to the mentioned methods across the compiler which
are potentially wrong.

Thanks to Jason for the test case!
@retronym
Copy link
Member

LGTM

@gkossakowski
Copy link
Contributor

PLS REBUILD ALL

@scala-jenkins
Copy link

(kitty-note-to-self: ignore 59735555)
🐱 Roger! Rebuilding pr-scala for 347f01d. 🚨

@gkossakowski
Copy link
Contributor

PLS REBUILD ALL

IDE fails with:

[sbt-republish] [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[sbt-republish] [warn]  ::          UNRESOLVED DEPENDENCIES         ::
[sbt-republish] [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[sbt-republish] [warn]  :: org.scala-lang.modules#scala-xml_2.11.3-347f01d-SNAPSHOT;1.0.2: java.text.ParseException: inconsistent module descriptor file found in '/localhome/jenkins/b/workspace/pr-scala-integrate-ide/target/zinc/target-0.9.2/project-builds/sbt-republish-4d6c256275a37d17f27db4d424569c976bfc0952/.dbuild/local-repo/0/org.scala-lang.modules/scala-xml_2.11.3-347f01d-SNAPSHOT/1.0.2/ivys/ivy.xml': bad module name: expected='scala-xml_2.11.3-347f01d-SNAPSHOT' found='scala-xml_2.11.3-fa40ff3-SNAPSHOT'; 
[sbt-republish] [warn]  :: org.scala-lang.modules#scala-parser-combinators_2.11.3-347f01d-SNAPSHOT;1.0.2: java.text.ParseException: inconsistent module descriptor file found in '/localhome/jenkins/b/workspace/pr-scala-integrate-ide/target/zinc/target-0.9.2/project-builds/sbt-republish-4d6c256275a37d17f27db4d424569c976bfc0952/.dbuild/local-repo/0/org.scala-lang.modules/scala-parser-combinators_2.11.3-347f01d-SNAPSHOT/1.0.2/ivys/ivy.xml': bad module name: expected='scala-parser-combinators_2.11.3-347f01d-SNAPSHOT' found='scala-parser-combinators_2.11.3-fa40ff3-SNAPSHOT'; 
[sbt-republish] [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[sbt-republish] [info] Wrote /localhome/jenkins/b/workspace/pr-scala-integrate-ide/target/zinc/target-0.9.2/project-builds/sbt-republish-4d6c256275a37d17f27db4d424569c976bfc0952/sbt-interface/target/sbt-interface-0.13.6-on-2.11.3.v20141015-082102-347f01d-SNAPSHOT-347f01d464-for-IDE.pom
[sbt-republish] sbt.ResolveException: unresolved dependency: org.scala-lang.modules#scala-xml_2.11.3-347f01d-SNAPSHOT;1.0.2: java.text.ParseException: inconsistent module descriptor file found in '/localhome/jenkins/b/workspace/pr-scala-integrate-ide/target/zinc/target-0.9.2/project-builds/sbt-republish-4d6c256275a37d17f27db4d424569c976bfc0952/.dbuild/local-repo/0/org.scala-lang.modules/scala-xml_2.11.3-347f01d-SNAPSHOT/1.0.2/ivys/ivy.xml': bad module name: expected='scala-xml_2.11.3-347f01d-SNAPSHOT' found='scala-xml_2.11.3-fa40ff3-SNAPSHOT'; 
[sbt-republish] unresolved dependency: org.scala-lang.modules#scala-parser-combinators_2.11.3-347f01d-SNAPSHOT;1.0.2: java.text.ParseException: inconsistent module descriptor file found in '/localhome/jenkins/b/workspace/pr-scala-integrate-ide/target/zinc/target-0.9.2/project-builds/sbt-republish-4d6c256275a37d17f27db4d424569c976bfc0952/.dbuild/local-repo/0/org.scala-lang.modules/scala-parser-combinators_2.11.3-347f01d-SNAPSHOT/1.0.2/ivys/ivy.xml': bad module name: expected='scala-parser-combinators_2.11.3-347f01d-SNAPSHOT' found='scala-parser-combinators_2.11.3-fa40ff3-SNAPSHOT';

I hope this one will just go away...

@scala-jenkins
Copy link

(kitty-note-to-self: ignore 59757313)
🐱 Roger! Rebuilding pr-scala for 347f01d. 🚨

@som-snytt
Copy link
Contributor

I hit this with the repl update to javap -fun. Naturally I named something lambdaMethods. Wikipedia article on lambda has a secondary reference that says the ancient pronunciation was labda, so I went with that. I can't write lambda without thinking of baby sheep.

@gkossakowski
Copy link
Contributor

PLS REBUILD ALL

@scala-jenkins
Copy link

(kitty-note-to-self: ignore 59811500)
🐱 Roger! Rebuilding pr-scala for 347f01d. 🚨

gkossakowski added a commit that referenced this pull request Oct 20, 2014
SI-8900 Don't assert !isDelambdafyFunction, it may not be accurate
@gkossakowski gkossakowski merged commit 850899b into scala:2.11.x Oct 20, 2014
@lrytz lrytz deleted the t8900 branch November 7, 2014 09:18
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

Successfully merging this pull request may close these issues.

6 participants