From bae7646c9846424e46f204201ea3a34339ec4eef Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 6 Dec 2025 15:31:26 -0800 Subject: [PATCH 1/4] Issue Illegal Identifier for names with dollars --- .../dotty/tools/dotc/parsing/Parsers.scala | 38 ++-- .../tools/dotc/reporting/ErrorMessageID.scala | 1 + .../dotty/tools/dotc/reporting/messages.scala | 18 ++ tests/neg/i18234.scala | 163 ++++++++++++++++++ tests/pos/i18234.scala | 3 + 5 files changed, 210 insertions(+), 13 deletions(-) create mode 100755 tests/neg/i18234.scala create mode 100644 tests/pos/i18234.scala diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 85cdcfed6950..48b6457f4002 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1286,9 +1286,7 @@ object Parsers { if (isIdent) { val name = in.name if name == nme.CONSTRUCTOR || name == nme.STATIC_CONSTRUCTOR then - report.error( - em"""Illegal backquoted identifier: `` and `` are forbidden""", - in.sourcePos()) + report.error(IllegalIdentifier(name), in.sourcePos()) in.nextToken() name } @@ -1297,6 +1295,19 @@ object Parsers { nme.ERROR } + /** An ident that is checked to be clean for a definition. */ + def defName(): TermName = + val checkable = in.token != BACKQUOTED_IDENT + val start = in.sourcePos() + ident().tap: name => + if checkable && name.toSimpleName.contains('$') then + report.error(IllegalIdentifier(name), start) + + extension (nameTree: NameTree) def checkName: nameTree.type = + if !isBackquoted(nameTree) && nameTree.name.toSimpleName.contains('$') then + report.error(IllegalIdentifier(nameTree.name), nameTree.srcPos) + nameTree + /** Accept identifier and return Ident with its name as a term name. */ def termIdent(): Ident = makeIdent(in.token, in.offset, ident()) @@ -1309,7 +1320,7 @@ object Parsers { val tree = Ident(name) if (tok == BACKQUOTED_IDENT) tree.pushAttachment(Backquoted, ()) - // Make sure that even trees with parsing errors have a offset that is within the offset + // Make sure that even trees with parsing errors have an offset that is within the offset val errorOffset = offset min (in.lastOffset - 1) if (tree.name == nme.ERROR && tree.span == NoSpan) tree.withSpan(Span(errorOffset, errorOffset)) else atSpan(offset)(tree) @@ -1379,7 +1390,7 @@ object Parsers { /** QualId ::= id {`.' id} */ - def qualId(): Tree = dotSelectors(termIdent()) + def qualId(): Tree = dotSelectors(termIdent().checkName) /** SimpleLiteral ::= [‘-’] integerLiteral * | [‘-’] floatingPointLiteral @@ -3773,7 +3784,7 @@ object Parsers { mods |= Param } atSpan(start, nameStart) { - val name = ident() + val name = defName() acceptColon() if (in.token == ARROW && paramOwner.isClass && !mods.is(Local)) syntaxError(VarValParametersMayNotBeCallByName(name, mods.is(Mutable))) @@ -4103,6 +4114,7 @@ object Parsers { case IdPattern(id, t) :: Nil if t.isEmpty => val vdef = ValDef(id.name.asTermName, tpt, rhs) if (isBackquoted(id)) vdef.pushAttachment(Backquoted, ()) + else checkName(id) finalizeDef(vdef, mods, start) case _ => def isAllIds = lhs.forall { @@ -4158,7 +4170,7 @@ object Parsers { } else { val mods1 = addFlag(mods, Method) - val ident = termIdent() + val ident = termIdent().checkName var name = ident.name.asTermName val paramss = if sourceVersion.enablesClauseInterleaving then @@ -4229,7 +4241,7 @@ object Parsers { newLinesOpt() atSpan(start, nameStart) { - val nameIdent = typeIdent() + val nameIdent = typeIdent().checkName val isCapDef = gobbleHat() val tname = nameIdent.name.asTypeName val tparams = typeParamClauseOpt(ParamOwner.Hk) @@ -4321,7 +4333,7 @@ object Parsers { /** ClassDef ::= id ClassConstr TemplateOpt */ def classDef(start: Offset, mods: Modifiers): TypeDef = atSpan(start, nameStart) { - classDefRest(start, mods, ident().toTypeName) + classDefRest(start, mods, defName().toTypeName) } def classDefRest(start: Offset, mods: Modifiers, name: TypeName): TypeDef = @@ -4346,7 +4358,7 @@ object Parsers { /** ObjectDef ::= id TemplateOpt */ def objectDef(start: Offset, mods: Modifiers): ModuleDef = atSpan(start, nameStart) { - val name = ident() + val name = defName() val templ = templateOpt(emptyConstructor) finalizeDef(ModuleDef(name, templ), mods, start) } @@ -4366,7 +4378,7 @@ object Parsers { */ def enumDef(start: Offset, mods: Modifiers): TypeDef = atSpan(start, nameStart) { val mods1 = checkAccessOnly(mods, "") - val modulName = ident() + val modulName = defName() val clsName = modulName.toTypeName val constr = classConstr(ParamOwner.Class) val templ = template(constr, isEnum = true) @@ -4380,10 +4392,10 @@ object Parsers { accept(CASE) atSpan(start, nameStart) { - val id = termIdent() + val id = termIdent().checkName if (in.token == COMMA) { in.nextToken() - val ids = commaSeparated(() => termIdent()) + val ids = commaSeparated(() => termIdent().checkName) if ctx.settings.Whas.enumCommentDiscard then in.getDocComment(start).foreach: comm => warning( diff --git a/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala b/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala index 5f5a0c01db17..3d53d5365955 100644 --- a/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala +++ b/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala @@ -236,6 +236,7 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe case DefaultShadowsGivenID // errorNumber: 220 case RecurseWithDefaultID // errorNumber: 221 case EncodedPackageNameID // errorNumber: 222 + case IllegalIdentifierID // errorNumber: 223 def errorNumber = ordinal - 1 diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index 159b3c9a905e..fc6473440699 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -3749,3 +3749,21 @@ final class EncodedPackageName(name: Name)(using Context) extends SyntaxMsg(Enco |or `myfile-test.scala` can produce encoded names for the generated package objects. | |In this case, the name `$name` is encoded as `${name.encode}`.""" + +final class IllegalIdentifier(name: Name)(using Context) extends SyntaxMsg(IllegalIdentifierID): + override protected def msg(using Context): String = + name match + case nme.CONSTRUCTOR | nme.STATIC_CONSTRUCTOR => + "Illegal backquoted identifier: `` and `` are forbidden" + case _ => + i"The identifier `$name` should not contain `$$`, which is reserved for internal compiler use." + override protected def explain(using Context): String = + name match + case nme.CONSTRUCTOR | nme.STATIC_CONSTRUCTOR => + "Names can include unusual characters when enclosed in backquotes, but `` and `` are reserved." + case _ => + i"""User identifiers may be encoded with embedded `$$`, and other compiler artifacts + |may rely on using `$$` with specific meanings. + | + |The prohibition against explicit `$$` may be ignored by enclosing the identifier in backquotes + |at the definition site.""" diff --git a/tests/neg/i18234.scala b/tests/neg/i18234.scala new file mode 100755 index 000000000000..dab68db22db9 --- /dev/null +++ b/tests/neg/i18234.scala @@ -0,0 +1,163 @@ +/* vals */ +val goodVal = 1 +val $startVal = 1 // error +val mid$dleVal = 1 // error +val endVal$ = 1 // error + +def testValUsage = + $startVal + endVal$ // ok, should only warn on declaration not on usage + +/* functions */ +def $funcStart() = 3 // error +def func$Middle() = 3 // error +def funcEnd$() = 3 // error + +def func1badArg(goodArg: Int, bad$Arg: Int) = 5 // error +def func1badArgAndUsageDoesNotThrowWarning(goodArg: Int, bad$Arg: Int) = bad$Arg // error +def func2badArgs(goodArg: Int, bad$Arg: Int, bad$arg2: String) = 5 // error // error +def multilineFunc( + goodArg: Int, + badAr$g: Int // error +) = 1 + +def testFuncUsaage = + $funcStart() + func1badArg(1, 2) // ok, should only warn on declaration not on usage + +/* types */ +type GoodType = Int +type $StartType = Int // error +type Middle$Type = Int // error +type EndType$ = Int // error + +val typedVal: Middle$Type = 2 // ok, should only warn on declaration not on usage +def funcWithDollarTypes(foo: $StartType): Middle$Type = 2 // ok, should only warn on declaration not on usage + +/* enums */ +enum GoodEnum: + case GoodCase + case $BadCaseStart // error + case BadCase$Middle // error + case BadCaseEnd$ // error + +enum $BadEnumStart: // error + case GoodCase + case $BadCase // error + +enum BadEnum$Middle: // error + case GoodCase + case Bad$Case // error + +enum BadEnumEnd$: // error + case GoodCase + case BadCase$ // error + +enum E$numWithEndKeyword: // error + case SomeCase +end E$numWithEndKeyword // ok + +def TestEnumUsage(a: $BadEnumStart): Int = // ok, should only warn on declaration not on usage + a match + case $BadEnumStart.GoodCase => 1 + case $BadEnumStart.$BadCase => 2 // ok, should only warn on declaration not on usage + +/* objects */ +object $ObjectStart: // error + val goodVal = 1 + val $badVal = 2 // error + +object Object$Middle: // error + val goodVal = 1 + val bad$Val = 2 // error + +object ObjectEnd$: // error + val goodVal = 1 + val badVal$ = 2 // error + +object GoodObject: + val goodVal = 1 + val b$adVal = 2 // error + +object Ob$jectWithEndKeyword: // error + val someVal = 1 +end Ob$jectWithEndKeyword // ok + +val testObjectUsage = ObjectEnd$.badVal$ // ok, should only warn on declaration not on usage + +/* case classes */ +case class $InlineCaseClassStart(someField: Int) // error +case class InlineCaseClass$Middle(someField: Int) // error +case class InlineCaseClassEnd$(someField: Int) // error + +case class InlineCaseClass(goodField: Int, badFiel$d: Int) // error + +case class $CaseClassStart( // error + somefield: Int, + b$adfield: Int // error +) + +case class CaseClass$Middle( // error + somefield: Int, + bad$Field: Int // error +) + +case class CaseClassEnd$( // error + somefield: Int, + badField$: Int // error +) + +// companion oject +object CaseClassEnd$: // error + val food = 1 + +val testCaseClassUsage = CaseClass$Middle(somefield = 1, bad$Field = 2) // ok, should only warn on declaration not on usage + +/* classes */ +class GoodClass +class $StartClass // error +class Middle$Class // error +class EndClass$ // error + +class Cla$$( // error + var goodMember: Int, + var badM$ember: Int // error +): + def goodMethod(x: Int) = badM$ember // ok, only checking if the method name does not contain a dollar sign + def bad$Method(y: Int) = goodMember // error + def methodWithBadArgNames(b$ad$arg: Int) = goodMember // error + def method$WithEndKeyword() = // error + 3 + end method$WithEndKeyword +end Cla$$ // ok + +def testUsage = + val instatiation = new Cla$$(goodMember = 1, badM$ember = 2) // ok, should only warn on declaration not on usage + instatiation.bad$Method(1) // ok, should only warn on declaration not on usage + instatiation.methodWithBadArgNames(2) // ok, should only warn on declaration not on usage + + +/* traits */ +trait GoodTrait +trait $BadTraitStart // error +trait BadTrait$Middle // error +trait BadTraitEnd$ // error + +class TestTraitUsage extends $BadTraitStart // ok, should only warn on declaration not on usage + +package GoodPackage: + val goodVal = 1 + val b$adVal = 2 // error + +package $BadPackageStart: // error + val goodVal = 1 + val $badVal = 2 // error + +package BadPackage$Middle: // error + val goodVal = 1 + val bad$Val = 2 // error + +package BadPackageEnd$ : // error + val goodVal = 1 + val badVal$ = 2 // error + +class BadConstructor: + def ``() = () // error // error diff --git a/tests/pos/i18234.scala b/tests/pos/i18234.scala new file mode 100644 index 000000000000..e807734775f1 --- /dev/null +++ b/tests/pos/i18234.scala @@ -0,0 +1,3 @@ + +class `C$Z`: + override def toString = "C$Z" From 81fb62409e725aec66d8aa50bf2c06983f7961de Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 6 Dec 2025 18:37:49 -0800 Subject: [PATCH 2/4] Migrate the dollar check --- compiler/src/dotty/tools/dotc/config/MigrationVersion.scala | 1 + compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 4 ++-- tests/neg/i18234.scala | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala b/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala index 9b1b4b5f07cc..953b6cd03964 100644 --- a/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala +++ b/compiler/src/dotty/tools/dotc/config/MigrationVersion.scala @@ -34,6 +34,7 @@ enum MigrationVersion(val warnFrom: SourceVersion, val errorFrom: SourceVersion) case GivenSyntax extends MigrationVersion(future, future) case ImplicitParamsWithoutUsing extends MigrationVersion(`3.7`, future) case Scala2Implicits extends MigrationVersion(future, future) + case IdentifierDollars extends MigrationVersion(`3.8`, `3.9`) require(warnFrom.ordinal <= errorFrom.ordinal) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 48b6457f4002..74c6a583e237 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1301,11 +1301,11 @@ object Parsers { val start = in.sourcePos() ident().tap: name => if checkable && name.toSimpleName.contains('$') then - report.error(IllegalIdentifier(name), start) + report.errorOrMigrationWarning(IllegalIdentifier(name), start, MigrationVersion.IdentifierDollars) extension (nameTree: NameTree) def checkName: nameTree.type = if !isBackquoted(nameTree) && nameTree.name.toSimpleName.contains('$') then - report.error(IllegalIdentifier(nameTree.name), nameTree.srcPos) + report.errorOrMigrationWarning(IllegalIdentifier(nameTree.name), nameTree.srcPos, MigrationVersion.IdentifierDollars) nameTree /** Accept identifier and return Ident with its name as a term name. */ diff --git a/tests/neg/i18234.scala b/tests/neg/i18234.scala index dab68db22db9..121710642eef 100755 --- a/tests/neg/i18234.scala +++ b/tests/neg/i18234.scala @@ -1,3 +1,4 @@ +//> using options -source:3.9 /* vals */ val goodVal = 1 val $startVal = 1 // error From 19ed7addcb41ef54e5130de091239b0c3a328556 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 6 Dec 2025 19:10:43 -0800 Subject: [PATCH 3/4] Check patvar names --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 3 +++ tests/neg/i18234.scala | 5 +++++ tests/pos/i18234.scala | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 74c6a583e237..ace632f13b9c 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3425,6 +3425,9 @@ object Parsers { p = atSpan(startOffset(t), in.offset) { TypeApply(p, typeArgs(namedOK = false, wildOK = false)) } if (in.token == LPAREN) p = atSpan(startOffset(t), in.offset) { Apply(p, argumentPatterns()) } + p match + case nt: NameTree if isVarPattern(nt) => checkName(nt) + case _ => p /** Patterns ::= Pattern [`,' Pattern] diff --git a/tests/neg/i18234.scala b/tests/neg/i18234.scala index 121710642eef..f28be4edffc0 100755 --- a/tests/neg/i18234.scala +++ b/tests/neg/i18234.scala @@ -162,3 +162,8 @@ package BadPackageEnd$ : // error class BadConstructor: def ``() = () // error // error + +def patvar[A](x: Option[A]) = + x match + case Some(funky$thing) => true // error + case _ => false diff --git a/tests/pos/i18234.scala b/tests/pos/i18234.scala index e807734775f1..4abe0d91037b 100644 --- a/tests/pos/i18234.scala +++ b/tests/pos/i18234.scala @@ -1,3 +1,9 @@ +//> using options -Werror class `C$Z`: override def toString = "C$Z" + + def patvar[A](x: Option[A]) = + x match + case Some(`funky$thing` @ _) => true + case _ => false From 9754e00af4442ce97f1bb2377254edfaa0f7128a Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sun, 7 Dec 2025 04:52:08 -0800 Subject: [PATCH 4/4] Adjustments for dollars --- .../dotc/core/classfile/ClassfileTastyUUIDParser.scala | 2 +- library/src/scala/collection/immutable/List.scala | 2 +- .../test/dotty/tools/pc/tests/CompilerCachingSuite.scala | 6 +++--- repl/test-resources/type-printer/source-compatible | 2 +- scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala | 2 +- tests/init/pos/i10549a.scala | 2 +- tests/init/pos/i9664.scala | 2 +- tests/init/warn/java1.scala | 2 +- tests/neg/i15381.scala | 2 +- tests/neg/i4986c.scala | 2 +- tests/warn/{scala2-t11681.scala => t11681.scala} | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) rename tests/warn/{scala2-t11681.scala => t11681.scala} (99%) diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileTastyUUIDParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileTastyUUIDParser.scala index e2220e40c6b4..4a3671251c23 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileTastyUUIDParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileTastyUUIDParser.scala @@ -104,6 +104,6 @@ class ClassfileTastyUUIDParser(classfile: AbstractFile)(ictx: Context) { class ConstantPool(using in: DataReader) extends ClassfileParser.AbstractConstantPool { def getClassOrArrayType(index: Int)(using ctx: Context, in: DataReader): Type = throw new UnsupportedOperationException def getClassSymbol(index: Int)(using ctx: Context, in: DataReader): Symbol = throw new UnsupportedOperationException - def getType(index: Int, isVarargs: Boolean)(using x$3: Context, x$4: DataReader): Type = throw new UnsupportedOperationException + def getType(index: Int, isVarargs: Boolean)(using Context, DataReader): Type = throw new UnsupportedOperationException } } diff --git a/library/src/scala/collection/immutable/List.scala b/library/src/scala/collection/immutable/List.scala index f105cefa4142..f1eb50460071 100644 --- a/library/src/scala/collection/immutable/List.scala +++ b/library/src/scala/collection/immutable/List.scala @@ -652,7 +652,7 @@ final case class :: [+A](override val head: A, private[scala] var next: List[A @ override def tail: List[A] = next @publicInBinary - private[::] def next$access$1 = next + private[::] def `next$access$1` = next } diff --git a/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala index 9a6f2af24efb..20e03b78491c 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala @@ -30,7 +30,7 @@ class CompilerCachingSuite extends BasePCSuite: case pc: ScalaPresentationCompiler => val compilations = pc.compilerAccess.withNonInterruptableCompiler(-1, EmptyCancelToken) { driver => driver.compiler().currentCtx.runId - }(emptyQueryContext).get(timeout.length, timeout.unit) + }(using emptyQueryContext).get(timeout.length, timeout.unit) assertEquals(expected, compilations, s"Expected $expected compilations but got $compilations") case _ => throw IllegalStateException("Presentation compiler should always be of type of ScalaPresentationCompiler") @@ -39,7 +39,7 @@ class CompilerCachingSuite extends BasePCSuite: case pc: ScalaPresentationCompiler => pc.compilerAccess.withNonInterruptableCompiler(null, EmptyCancelToken) { driver => driver.compiler().currentCtx - }(emptyQueryContext).get(timeout.length, timeout.unit) + }(using emptyQueryContext).get(timeout.length, timeout.unit) case _ => throw IllegalStateException("Presentation compiler should always be of type of ScalaPresentationCompiler") private def emptyQueryContext = PcQueryContext(None, () => "")(using EmptyReportContext()) @@ -133,7 +133,7 @@ class CompilerCachingSuite extends BasePCSuite: checkCompilationCount(6) - private val testFunctions: List[OffsetParams => CompletableFuture[_]] = List( + private val testFunctions: List[OffsetParams => CompletableFuture[?]] = List( presentationCompiler.complete(_), presentationCompiler.convertToNamedArguments(_, Collections.emptyList()), presentationCompiler.autoImports("a", _, false), diff --git a/repl/test-resources/type-printer/source-compatible b/repl/test-resources/type-printer/source-compatible index d0773a11a795..95ab920bbe18 100644 --- a/repl/test-resources/type-printer/source-compatible +++ b/repl/test-resources/type-printer/source-compatible @@ -7,7 +7,7 @@ val m: def i_=(x$1: Int): Unit; type N = Int; val l: List[Int]; def p[T](t: T): String } = Bag() -scala> type t = Bag { val f: Int; def g: Int; def h(i: Int): Int; val i: Int; def i_=(x$1: Int): Unit; type N = Int; val l: List[Int]; val s: String @unchecked } +scala> type t = Bag { val f: Int; def g: Int; def h(i: Int): Int; val i: Int; def i_=(`x$1`: Int): Unit; type N = Int; val l: List[Int]; val s: String @unchecked } // defined alias type t = Bag{ diff --git a/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala b/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala index b23e5647f6fb..15e168467c8a 100644 --- a/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala +++ b/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala @@ -11,7 +11,7 @@ import scala.jdk.CollectionConverters._ case class LazyEntry(getKey: String, value: () => String) extends JMapEntry[String, Object]: lazy val getValue: Object = value() - def setValue(x$0: Object): Object = ??? + def setValue(`x$0`: Object): Object = ??? case class LoadedTemplate( templateFile: TemplateFile, diff --git a/tests/init/pos/i10549a.scala b/tests/init/pos/i10549a.scala index 23ccbff747f4..f235e060006f 100644 --- a/tests/init/pos/i10549a.scala +++ b/tests/init/pos/i10549a.scala @@ -2,6 +2,6 @@ class Wrap { class E object E { final val A = new E {} - val $values = Array(A) + val `$values` = Array(A) } } diff --git a/tests/init/pos/i9664.scala b/tests/init/pos/i9664.scala index 34bcd84e6ee9..334c77342938 100644 --- a/tests/init/pos/i9664.scala +++ b/tests/init/pos/i9664.scala @@ -2,7 +2,7 @@ object Wrap1 { class E object E { final val A = E() - val $values = Array(A) + val `$values` = Array(A) } } object Wrap2 { diff --git a/tests/init/warn/java1.scala b/tests/init/warn/java1.scala index 36044413d2ea..51cf32275aeb 100644 --- a/tests/init/warn/java1.scala +++ b/tests/init/warn/java1.scala @@ -5,7 +5,7 @@ class A extends Spliterator.OfDouble: def characteristics() = 10 def estimateSize() = 10 def trySplit() = ??? - def tryAdvance(x$0: java.util.function.DoubleConsumer): Boolean = false + def tryAdvance(`x$0`: java.util.function.DoubleConsumer): Boolean = false val m = n + 1 val n = 10 // warn diff --git a/tests/neg/i15381.scala b/tests/neg/i15381.scala index a0328931b36e..ab8909a35658 100644 --- a/tests/neg/i15381.scala +++ b/tests/neg/i15381.scala @@ -1,6 +1,6 @@ //> using options -Vprint:parser -case class $[A](value: A) +case class `$`[A](value: A) def g: Int = $ // error diff --git a/tests/neg/i4986c.scala b/tests/neg/i4986c.scala index 13b608a69707..41b473f3ed8f 100644 --- a/tests/neg/i4986c.scala +++ b/tests/neg/i4986c.scala @@ -14,7 +14,7 @@ class Outer[A] { } } -trait X$Y +trait `X$Y` @implicitNotFound(msg = "There's no U[${X}, ${Y}, ${Z}]") trait U[X, Y[_], Z[_, ZZ]] { diff --git a/tests/warn/scala2-t11681.scala b/tests/warn/t11681.scala similarity index 99% rename from tests/warn/scala2-t11681.scala rename to tests/warn/t11681.scala index adbf5ea41299..063c7e93703e 100644 --- a/tests/warn/scala2-t11681.scala +++ b/tests/warn/t11681.scala @@ -106,4 +106,4 @@ object Answers { def answer: Int = 42 } -val a$1 = 2 +val `a$1` = 2