From 2708c8c367a37fce87a655850908b10d766abb1c Mon Sep 17 00:00:00 2001 From: i10416 Date: Fri, 1 Mar 2024 01:41:24 +0900 Subject: [PATCH] fix(#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 ``` --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 1f0adc9f1421..6d537ea62c7c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -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)