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

Backport "fix(#17255): cannot find Scala companion module from Java" to LTS #20959

Merged
merged 7 commits into from
Jul 3, 2024

Conversation

WojciechMazur
Copy link
Contributor

Backports #19773 to the LTS branch.

PR submitted by the release tooling.
[skip ci]

WojciechMazur and others added 7 commits July 2, 2024 22:30
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]
Avoid skipping searchin a member by the original name even when name is likely
companion module name.

[Cherry-picked 4cb34e5]
Test imported type as well as fully-qualified type to check `findRef` codepath.

Co-authored-by: Jamie Thompson <[email protected]>
[Cherry-picked 96c91da]
Base automatically changed from lts-19802 to lts-3.3 July 3, 2024 08:28
@WojciechMazur
Copy link
Contributor Author

No regressions detected in the community build up to lts-19921.

Reference

@WojciechMazur WojciechMazur merged commit 9b2cbf0 into lts-3.3 Jul 3, 2024
19 checks passed
@WojciechMazur WojciechMazur deleted the lts-19773 branch July 3, 2024 08:29
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.

2 participants