Use Java rules for member lookup in .java sources#7671
Merged
retronym merged 4 commits intoscala:2.13.xfrom Feb 11, 2019
Merged
Use Java rules for member lookup in .java sources#7671retronym merged 4 commits intoscala:2.13.xfrom
retronym merged 4 commits intoscala:2.13.xfrom
Conversation
47745f0 to
7b3790e
Compare
This was referenced Jan 23, 2019
Member
Author
|
Targetting at 2.13.x, but this would be a backport candidate for 2.12.9 |
For static innner classes, we need to check in the companion module of each base classes.
…mpanion class prefix
to avoid cluttering logic that 99% of time deals with Scala
7b3790e to
29fe15b
Compare
adriaanm
approved these changes
Feb 11, 2019
Contributor
adriaanm
left a comment
There was a problem hiding this comment.
I push -f'ed my review (just a small tweak). Let me know if this looks good to you. Let's squash the commits before merging.
retronym
added a commit
to retronym/scala
that referenced
this pull request
Feb 12, 2019
- Inherited type declarations are in scope in Java code - For static innner classes, we need to check in the companion module of each base classes. - Incorporate and accomodate test case from scala#6053 - Tests to java code referring to module-class owned classes via companion class prefix Backport of scala#7671
Member
Author
|
Backport submitted in #7738 |
retronym
added a commit
to retronym/scala
that referenced
this pull request
Feb 12, 2019
- Inherited type declarations are in scope in Java code - For static innner classes, we need to check in the companion module of each base classes. - Incorporate and accomodate test case from scala#6053 - Tests to java code referring to module-class owned classes via companion class prefix Backport of scala#7671
Contributor
|
"Java rules!" |
retronym
referenced
this pull request
Mar 21, 2019
Contributor
|
Awesome -- this also obviates the need for a leaky encoding in JavaParsers: scala/src/compiler/scala/tools/nsc/javac/JavaParsers.scala Lines 760 to 770 in 7c9e372 Those forwarders attempt to encode the rules that this PR implements directly. They cause issues when refchecks becomes more accurate because they are inherited. |
adriaanm
added a commit
to adriaanm/scala
that referenced
this pull request
Mar 21, 2019
It's subsumed by Jason's improvements to name resolution in scala#7671. The leak yielded spurious errors in mixed Scala/Java compilation (akka-http). Also, pull up exemption for synthetic members from refchecks; it makes no sense to bother the user about members synthesized by the compiler. We could get early warnings this way, but eventually they'll pop up as VerifyErrors...
adriaanm
added a commit
to adriaanm/scala
that referenced
this pull request
Mar 21, 2019
It's subsumed by Jason's improvements to name resolution in scala#7671. The leak yielded spurious errors in mixed Scala/Java compilation (akka-http).
retronym
pushed a commit
to retronym/scala
that referenced
this pull request
May 23, 2019
It's subsumed by Jason's improvements to name resolution in scala#7671. The leak yielded spurious errors in mixed Scala/Java compilation (akka-http). (cherry picked from commit 8529be7)
retronym
added a commit
to retronym/scala
that referenced
this pull request
Jun 19, 2019
Fixed in scala#7671, which was backported to 2.12.x in scala#7738
i10416
added a commit
to i10416/dotty
that referenced
this pull request
Feb 24, 2024
To find Scala companion mudule from Java in mixed sources, we should strip module suffix `$`. This provides workaround for scala#17255, but it requires some refinment to fix it because not-fully-qualified type like the following example still fails to compile due to missing symbol. ```java package example; public class Bar { private static final Foo$ MOD = Foo$.MODULE; } ``` This is because `pre` in `javaFindMember` for `Foo` in the case above is `<root>`, not `example` and therefore `pre.findMember` looks for `<root>.Foo` instead of `example.Foo`. I'm not sure whether the qualifier is intentionally dropped. References - scala#12884 - scala/scala#7671
WojciechMazur
added a commit
to scala/scala3
that referenced
this pull request
Jul 2, 2024
To find Scala companion mudule from Java in mixed sources, we should strip module suffix `$`. This provides workaround for #17255, but it requires some refinment to fix it because not-fully-qualified type like the following example still fails to compile due to missing symbol. ```java package example; public class Bar { private static final Foo$ MOD = Foo$.MODULE; } ``` This is because `pre` in `javaFindMember` for `Foo` in the case above is `<root>`, not `example` and therefore `pre.findMember` looks for `<root>.Foo` instead of `example.Foo`. I'm not sure whether the qualifier is intentionally dropped. References - #12884 - scala/scala#7671 [Cherry-picked 22d98d6][modified]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.