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

Fix Java TASTy of scala module class references #19806

Closed
bishabosha opened this issue Feb 28, 2024 · 0 comments · Fixed by #19827
Closed

Fix Java TASTy of scala module class references #19806

bishabosha opened this issue Feb 28, 2024 · 0 comments · Fixed by #19827
Milestone

Comments

@bishabosha
Copy link
Member

bishabosha commented Feb 28, 2024

For some definitions

package p

object Module
public class J {
  public p.Module$ module() {
    return p.Module$.MODULE$;
  }
}

When the tree for J reaches TASTy (using -Yjava-tasty -Yjava-tasty-output foo.jar), this looks like

    87:       DEFDEF(12) 16 [module]
    90:         EMPTYCLAUSE
    91:         SELECTtpt 17 [Module$]
    93:           SHAREDtype 3
    95:         ELIDED
    96:           TYPEREF 19 [Module[ModuleClass]]
    98:             SHAREDtype 3
   100:         STATIC

really, tree 91 should be SELECTtpt 19 [Module[ModuleClass]]. This relies on the compiler (aka all TASTy clients) intrinsically knowing how to resolve Module$ when the definition is actually Module[ModuleClass]

Originally posted by @bishabosha in #19773 (comment)

i10416 added a commit to i10416/dotty that referenced this issue Feb 29, 2024
This commit makes the following diff to TASTy for i17255
files. The TASTy before this commit relied on the compiler (aka all TASTy clients)
intrinsically knowing how to resolve Module$ when the definition is actually Module[ModuleClass].

```sh
scalac tests/run/i17255/J.java tests/run/i17255/Module.scala -Yprint-tasty -Yjava-tasty
```

```diff
    90:         EMPTYCLAUSE
    91:         TERMREF 17 [Module]
    93:           SHAREDtype 12
    95:         ELIDED
    96:           SHAREDtype 91
    98:         STATIC
    99:       DEFDEF(12) 18 [module]
   102:         EMPTYCLAUSE
-  103:         SELECTtpt 19 [Module$]
+  103:         SELECTtpt 19 [Module[ModuleClass]]
   105:           SHAREDtype 3
   107:         ELIDED
   108:           TYPEREF 17 [Module]
   110:             SHAREDtype 3
   112:         STATIC
```
bishabosha added a commit that referenced this issue Mar 13, 2024
This commit makes the following diff to TASTy for i17255 files. The
TASTy before this commit relied on the compiler (aka all TASTy clients)
intrinsically knowing how to resolve Module$ when the definition is
actually Module[ModuleClass].

```sh
scalac tests/run/i17255/J.java tests/run/i17255/Module.scala -Yprint-tasty -Yjava-tasty
```

```diff
    90:         EMPTYCLAUSE
    91:         TERMREF 17 [Module]
    93:           SHAREDtype 12
    95:         ELIDED
    96:           SHAREDtype 91
    98:         STATIC
    99:       DEFDEF(12) 18 [module]
   102:         EMPTYCLAUSE
-  103:         SELECTtpt 19 [Module$]
+  103:         SELECTtpt 19 [Module[ModuleClass]]
   105:           SHAREDtype 3
   107:         ELIDED
   108:           TYPEREF 17 [Module]
   110:             SHAREDtype 3
   112:         STATIC
```

fixes #19806
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
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 a pull request may close this issue.

2 participants