Skip to content

Commit 2708c8c

Browse files
committed
fix(scala#19806): wrong tasty of scala module class reference
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 ```
1 parent 929714c commit 2708c8c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
688688
report.error(StableIdentPattern(tree, pt), tree.srcPos)
689689

690690
def typedSelect(tree0: untpd.Select, pt: Type, qual: Tree)(using Context): Tree =
691-
val selName = tree0.name
691+
val selName =
692+
if ctx.isJava && tree0.name.isTypeName && tree0.name.endsWith(StdNames.str.MODULE_SUFFIX) then
693+
tree0.name.stripModuleClassSuffix.moduleClassName
694+
else
695+
tree0.name
692696
val tree = cpy.Select(tree0)(qual, selName)
693697
val superAccess = qual.isInstanceOf[Super]
694698
val rawType = selectionType(tree, qual)

0 commit comments

Comments
 (0)