aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-15 11:13:37 +0100
committerMartin Odersky <odersky@gmail.com>2017-04-06 13:15:27 +0200
commit549bd812684e6f269610234ddefe8054dfb42746 (patch)
treebd757cc74c22a3c20c21b8b4abda97b56045e589
parentbf2f77e112bbc1d242a4f91b113ba3cc14c3dcc8 (diff)
downloaddotty-549bd812684e6f269610234ddefe8054dfb42746.tar.gz
dotty-549bd812684e6f269610234ddefe8054dfb42746.tar.bz2
dotty-549bd812684e6f269610234ddefe8054dfb42746.zip
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.
-rw-r--r--compiler/src/dotty/tools/dotc/ast/Desugar.scala12
-rw-r--r--tests/neg/illegal-param-names.scala1
2 files changed, 3 insertions, 10 deletions
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