Skip to content

Commit

Permalink
fix(scala#19806): wrong tasty of scala module class reference
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
i10416 committed Feb 29, 2024
1 parent 929714c commit 2708c8c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
report.error(StableIdentPattern(tree, pt), tree.srcPos)

def typedSelect(tree0: untpd.Select, pt: Type, qual: Tree)(using Context): Tree =
val selName = tree0.name
val selName =
if ctx.isJava && tree0.name.isTypeName && tree0.name.endsWith(StdNames.str.MODULE_SUFFIX) then
tree0.name.stripModuleClassSuffix.moduleClassName
else
tree0.name
val tree = cpy.Select(tree0)(qual, selName)
val superAccess = qual.isInstanceOf[Super]
val rawType = selectionType(tree, qual)
Expand Down

0 comments on commit 2708c8c

Please sign in to comment.