diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 821ceff67893..172dacf242d9 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -895,7 +895,7 @@ object desugar { */ def normalizeName(mdef: MemberDef, impl: Tree)(implicit ctx: Context): Name = { var name = mdef.name - if (name.isEmpty) name = name.likeSpaced(s"${inventName(impl)}_given".toTermName) + if (name.isEmpty) name = name.likeSpaced(avoidIllegalChars(s"${inventName(impl)}_given".toTermName.asSimpleName)) if (ctx.owner == defn.ScalaPackageClass && defn.reservedScalaClassNames.contains(name.toTypeName)) { def kind = if (name.isTypeName) "class" else "object" ctx.error(em"illegal redefinition of standard $kind $name", mdef.sourcePos) diff --git a/tests/run/i6902.scala b/tests/run/i6902.scala new file mode 100644 index 000000000000..68f966622714 --- /dev/null +++ b/tests/run/i6902.scala @@ -0,0 +1,9 @@ +object Test { + given [A] { def (a: A) <<< : A = a } + given { def (b: Int) <<<< : Int = b } + + def main(args: Array[String]): Unit = { + 1.<<< + 1.<<<< + } +}