Correctly handle overloads in mixed compilation with Java inner classes (fixing 2.12.16 regression)#10045
Merged
lrytz merged 1 commit intoscala:2.12.xfrom Jun 22, 2022
Merged
Correctly handle overloads in mixed compilation with Java inner classes (fixing 2.12.16 regression)#10045lrytz merged 1 commit intoscala:2.12.xfrom
lrytz merged 1 commit intoscala:2.12.xfrom
Conversation
In Java code, `A.B` can refer to a static or non-static member `B`. The Scala compiler models a selection of a static member as a selection from the companion object `A`. If the selection `A.B` (select from object `A`) doesn't yield a result, `handleMissing` creates a `SelectFromTypeTree` in a second try. Another special handling for Java is that `A.B` may refer to a static member `B` defined in a parent of `A`. This is done by `inCompanionForJavaStatic` in `typedSelect`. This lookup should only find static members (fixed by this PR). Before this PR, `A.B` for a non-static member B succeeded through `inCompanionForJavaStatic`, which means the qualifier `A` remained a reference to the synthetic companion object `A`. This means that the we obtained the a type `A.B` instead of `A#B`. After this PR, the `inCompanionForJavaStatic` lookup fails and we go to `handleMissing`, which changes the resulting tree into a `SelectFromTypeTree` (select from class A).
retronym
approved these changes
Jun 22, 2022
dongjoon-hyun
pushed a commit
to apache/spark
that referenced
this pull request
Sep 17, 2022
### What changes were proposed in this pull request? This PR aims to upgrade Scala to 2.12.17 - https://www.scala-lang.org/news/2.12.17 ### Why are the changes needed? The main [change](https://github.com/scala/scala/pulls?q=is%3Apr+sort%3Aupdated-desc+milestone%3A2.12.17+is%3Amerged+label%3Arelease-notes) fo this version as follows: - scala/scala#10109 - scala/scala#10075 - scala/scala#10108 - scala/scala#10045 - scala/scala#10063 - scala/scala#10042 - scala/scala#10040 - scala/scala#10095 ### Does this PR introduce _any_ user-facing change? Yes, this is a Scala version change. ### How was this patch tested? Existing Test Closes #37892 from LuciferYang/SPARK-40436. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
LuciferYang
added a commit
to LuciferYang/spark
that referenced
this pull request
Sep 20, 2022
### What changes were proposed in this pull request? This PR aims to upgrade Scala to 2.12.17 - https://www.scala-lang.org/news/2.12.17 ### Why are the changes needed? The main [change](https://github.com/scala/scala/pulls?q=is%3Apr+sort%3Aupdated-desc+milestone%3A2.12.17+is%3Amerged+label%3Arelease-notes) fo this version as follows: - scala/scala#10109 - scala/scala#10075 - scala/scala#10108 - scala/scala#10045 - scala/scala#10063 - scala/scala#10042 - scala/scala#10040 - scala/scala#10095 ### Does this PR introduce _any_ user-facing change? Yes, this is a Scala version change. ### How was this patch tested? Existing Test Closes apache#37892 from LuciferYang/SPARK-40436. Authored-by: yangjie01 <yangjie01@baidu.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
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.
In Java code,
A.Bcan refer to a static or non-static memberB. The Scala compiler models a selection of a static member as a selection from the companion objectA.If the selection
A.B(select from objectA) doesn't yield a result,handleMissingcreates aSelectFromTypeTreein a second try.Another special handling for Java is that
A.Bmay refer to a static memberBdefined in a parent ofA. This is done byinCompanionForJavaStaticintypedSelect. This lookup should only find static members (fixed by this PR).Before this PR,
A.Bfor a non-static member B succeeded throughinCompanionForJavaStatic, which means the qualifierAremained a reference to the synthetic companion objectA. This means that the we obtained the a typeA.Binstead ofA#B.After this PR, the
inCompanionForJavaStaticlookup fails and we go tohandleMissing, which changes the resulting tree into aSelectFromTypeTree(select from class A).Fixes scala/bug#12605.