diff options
author | Martin Odersky <odersky@gmail.com> | 2015-05-15 12:09:20 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-05-21 17:41:12 +0200 |
commit | 1f908b420e4efe944ea764bbba239472c9c3cc92 (patch) | |
tree | 25527f99d25f8ec0aa62134ca70d1ed0313cd2c2 /src/dotty/tools/dotc | |
parent | bf81fb62084f9e04e43906396c3ac5e307caca63 (diff) | |
download | dotty-1f908b420e4efe944ea764bbba239472c9c3cc92.tar.gz dotty-1f908b420e4efe944ea764bbba239472c9c3cc92.tar.bz2 dotty-1f908b420e4efe944ea764bbba239472c9c3cc92.zip |
Allow AnnotatedType in operands of `with`.
Brings in line with Scala 2 spec.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/parsing/Parsers.scala | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala index dd2c9bcaa..dbf57c22e 100644 --- a/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/src/dotty/tools/dotc/parsing/Parsers.scala @@ -679,25 +679,29 @@ object Parsers { def refinedTypeRest(t: Tree): Tree = { newLineOptWhenFollowedBy(LBRACE) - in.token match { - case AT => refinedTypeRest(atPos(t.pos.start) { Annotated(annot(), t) }) - case LBRACE => refinedTypeRest(atPos(t.pos.start) { RefinedTypeTree(t, refinement()) }) - case _ => t - } + if (in.token == LBRACE) refinedTypeRest(atPos(t.pos.start) { RefinedTypeTree(t, refinement()) }) + else t } - /** WithType ::= SimpleType {`with' SimpleType} (deprecated) + /** WithType ::= AnnotType {`with' AnnotType} (deprecated) */ - def withType(): Tree = withTypeRest(simpleType()) + def withType(): Tree = withTypeRest(annotType()) - def withTypeRest(t: Tree): Tree = { + def withTypeRest(t: Tree): Tree = if (in.token == WITH) { deprecationWarning("`with' as a type operator has been deprecated; use `&' instead") in.nextToken() AndTypeTree(t, withType()) } else t - } + + /** AnnotType ::= SimpleType {Annotation} + */ + def annotType(): Tree = annotTypeRest(simpleType()) + + def annotTypeRest(t: Tree): Tree = + if (in.token == AT) annotTypeRest(atPos(t.pos.start) { Annotated(annot(), t) }) + else t /** SimpleType ::= SimpleType TypeArgs * | SimpleType `#' Id @@ -1834,7 +1838,7 @@ object Parsers { /** ConstrApp ::= SimpleType {ParArgumentExprs} */ val constrApp = () => { - val t = simpleType() + val t = annotType() if (in.token == LPAREN) parArgumentExprss(wrapNew(t)) else t } |