Skip to content

Commit c84349a

Browse files
committed
Allow symbol literals only in Scala-2 mode
Offer to rewrite them to Symbol("...") calls.
1 parent 642ebaf commit c84349a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,15 @@ object Parsers {
659659
}
660660
val isNegated = negOffset < in.offset
661661
atPos(negOffset) {
662-
if (in.token == SYMBOLLIT) atPos(in.skipToken()) { SymbolLit(in.strVal) }
662+
if (in.token == SYMBOLLIT) {
663+
migrationWarningOrError(em"""symbol literal '${in.name} is no longer supported,
664+
|use a string literal "${in.name}" or an application Symbol("${in.name}") instead.""")
665+
if (in.isScala2Mode) {
666+
patch(source, Position(in.offset, in.offset + 1), "Symbol(\"")
667+
patch(source, Position(in.charOffset - 1), "\")")
668+
}
669+
atPos(in.skipToken()) { SymbolLit(in.strVal) }
670+
}
663671
else if (in.token == INTERPOLATIONID) interpolatedString(inPattern)
664672
else finish(in.token match {
665673
case CHARLIT => in.charVal

0 commit comments

Comments
 (0)