Skip to content

Commit 14f09b9

Browse files
committed
Handle semantic name in Java source code
This is the cheapest way to do it. There is no worry about correctness, as the code will be compiled by javac again.
1 parent 06afcc4 commit 14f09b9

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package parsing
55
import dotty.tools.dotc.core.Constants.Constant
66
import dotty.tools.dotc.core.Flags
77
import dotty.tools.dotc.core.Flags.FlagSet
8-
8+
import dotty.tools.dotc.core.NameOps.moduleClassName
99

1010
import JavaTokens._
1111
import JavaScanners._
@@ -206,7 +206,9 @@ object JavaParsers {
206206
if (in.token == IDENTIFIER) {
207207
val name = in.name
208208
in.nextToken()
209-
name
209+
if name(name.length - 1) == '$'
210+
then name.slice(0, name.length - 1).moduleClassName
211+
else name
210212
}
211213
else {
212214
accept(IDENTIFIER)
@@ -285,6 +287,8 @@ object JavaParsers {
285287
if name(0) >= 'A' && name(0) <= 'Z'
286288
then name.toTypeName
287289
else name.toTermName
290+
case _ => // semantic name from `O$`
291+
name.toTermName
288292

289293
optArrayBrackets {
290294
if (in.token == FINAL) in.nextToken()
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)