diff options
Diffstat (limited to 'src/dotty/tools/dotc/parsing/Parsers.scala')
-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 } |