From 549bd812684e6f269610234ddefe8054dfb42746 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 15 Mar 2017 11:13:37 +0100 Subject: Drop name checking scheme for type parameters It was a red herring. Symbolic names are expanded anyway to $plus / $minus, so they can't be confused with a variance prefix. --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 12 +++--------- tests/neg/illegal-param-names.scala | 1 - 2 files changed, 3 insertions(+), 10 deletions(-) delete mode 100644 tests/neg/illegal-param-names.scala diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 1531e67b3..10b522eaa 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -242,20 +242,14 @@ object desugar { * class C { type v C$T; type v T = C$T } */ def typeDef(tdef: TypeDef)(implicit ctx: Context): Tree = { - val checkedName = - if (tdef.name.hasVariance && tdef.mods.is(Param)) { - ctx.error(em"type parameter name may not start with `+' or `-'", tdef.pos) - ("$" + tdef.name).toTypeName - } - else tdef.name if (tdef.mods is PrivateLocalParam) { - val tparam = cpy.TypeDef(tdef)(name = checkedName.expandedName(ctx.owner)) + val tparam = cpy.TypeDef(tdef)(name = tdef.name.expandedName(ctx.owner)) .withMods(tdef.mods &~ PrivateLocal | ExpandedName) - val alias = cpy.TypeDef(tdef)(name = checkedName, rhs = refOfDef(tparam)) + val alias = cpy.TypeDef(tdef)(name = tdef.name, rhs = refOfDef(tparam)) .withMods(tdef.mods & VarianceFlags | PrivateLocalParamAccessor | Synthetic) Thicket(tparam, alias) } - else cpy.TypeDef(tdef)(name = checkedName) + else tdef } @sharable private val synthetic = Modifiers(Synthetic) diff --git a/tests/neg/illegal-param-names.scala b/tests/neg/illegal-param-names.scala deleted file mode 100644 index 9ca06798a..000000000 --- a/tests/neg/illegal-param-names.scala +++ /dev/null @@ -1 +0,0 @@ -class Test[++, --] // error // error -- cgit v1.2.3