Skip to content

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
lrytz:t12605
Jun 22, 2022
Merged

Correctly handle overloads in mixed compilation with Java inner classes (fixing 2.12.16 regression)#10045
lrytz merged 1 commit intoscala:2.12.xfrom
lrytz:t12605

Conversation

@lrytz
Copy link
Member

@lrytz lrytz commented Jun 9, 2022

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).

Fixes scala/bug#12605.

@scala-jenkins scala-jenkins added this to the 2.12.17 milestone Jun 9, 2022
@SethTisue SethTisue added prio:blocker release blocker (used only by core team, only near release time) release-notes worth highlighting in next release notes labels Jun 9, 2022
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).
@lrytz lrytz merged commit 689d72c into scala:2.12.x Jun 22, 2022
@SethTisue SethTisue removed the prio:blocker release blocker (used only by core team, only near release time) label Jul 9, 2022
@SethTisue SethTisue changed the title Only keep static members when looking up java static members Only keep static members when looking up Java static members Aug 31, 2022
@SethTisue SethTisue changed the title Only keep static members when looking up Java static members Correctly handle overloads in mixed compilation with Java inner classes (fixing 2.12.16 regression) Aug 31, 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes worth highlighting in next release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants