aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-04 17:27:10 +0100
committerMartin Odersky <odersky@gmail.com>2017-03-04 18:28:21 +0100
commit353a4d9f17b91d09dea3c9090c7a21e267372abe (patch)
tree08e1541da2f277c17da167ee6b9758a3f08e5f90 /compiler/src/dotty/tools/dotc/parsing/Parsers.scala
parent06d3f7aefa620ce006008955203d7f8f8dc7b605 (diff)
downloaddotty-353a4d9f17b91d09dea3c9090c7a21e267372abe.tar.gz
dotty-353a4d9f17b91d09dea3c9090c7a21e267372abe.tar.bz2
dotty-353a4d9f17b91d09dea3c9090c7a21e267372abe.zip
Drop named type parameters in classes
Drop the [type T] syntax, and what's associated to make it work. Motivation: It's an alternative way of doing things for which there seems to be little need. The implementation was provisional and bitrotted during the various iterations to introduce higher-kinded types. So in the end the complxity-cost for language and compiler was not worth the added benefit that [type T] parameters provide. Noe that we still accept _named arguments_ [A = T] in expressions; these are useful for specifying some parameters and letting others be inferred.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/parsing/Parsers.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/parsing/Parsers.scala34
1 files changed, 13 insertions, 21 deletions
diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
index b27bff37a..65c7a290d 100644
--- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -805,7 +805,7 @@ object Parsers {
private def simpleTypeRest(t: Tree): Tree = in.token match {
case HASH => simpleTypeRest(typeProjection(t))
case LBRACKET => simpleTypeRest(atPos(startOffset(t)) {
- AppliedTypeTree(t, typeArgs(namedOK = true, wildOK = true)) })
+ AppliedTypeTree(t, typeArgs(namedOK = false, wildOK = true)) })
case _ => t
}
@@ -1664,7 +1664,7 @@ object Parsers {
/* -------- PARAMETERS ------------------------------------------- */
/** ClsTypeParamClause::= `[' ClsTypeParam {`,' ClsTypeParam} `]'
- * ClsTypeParam ::= {Annotation} [{Modifier} type] [`+' | `-']
+ * ClsTypeParam ::= {Annotation} [`+' | `-']
* id [HkTypeParamClause] TypeParamBounds
*
* DefTypeParamClause::= `[' DefTypeParam {`,' DefTypeParam} `]'
@@ -1680,25 +1680,17 @@ object Parsers {
def typeParam(): TypeDef = {
val isConcreteOwner = ownerKind == ParamOwner.Class || ownerKind == ParamOwner.Def
val start = in.offset
- var mods = annotsAsMods()
- if (ownerKind == ParamOwner.Class) {
- mods = modifiers(start = mods)
- mods =
- atPos(start, in.offset) {
- if (in.token == TYPE) {
- val mod = atPos(in.skipToken()) { Mod.Type() }
- (mods | Param | ParamAccessor).withAddedMod(mod)
- } else {
- if (mods.hasFlags) syntaxError(TypeParamsTypeExpected(mods, ident()))
- mods | Param | PrivateLocal
- }
- }
- }
- else mods = atPos(start) (mods | Param)
- if (ownerKind != ParamOwner.Def) {
- if (isIdent(nme.raw.PLUS)) mods |= Covariant
- else if (isIdent(nme.raw.MINUS)) mods |= Contravariant
- if (mods is VarianceFlags) in.nextToken()
+ val mods = atPos(start) {
+ annotsAsMods() | {
+ if (ownerKind == ParamOwner.Class) Param | PrivateLocal
+ else Param
+ } | {
+ if (ownerKind != ParamOwner.Def)
+ if (isIdent(nme.raw.PLUS)) { in.nextToken(); Covariant }
+ else if (isIdent(nme.raw.MINUS)) { in.nextToken(); Contravariant }
+ else EmptyFlags
+ else EmptyFlags
+ }
}
atPos(start, nameStart) {
val name =