diff options
author | Martin Odersky <odersky@gmail.com> | 2007-02-07 18:30:46 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-02-07 18:30:46 +0000 |
commit | 67cf4f5e32bc036788ff7a5426a5f5c0bb07fb70 (patch) | |
tree | de57c9ef5cba16ea71ded0c3c20118ae74006873 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | |
parent | 9be1288dec994c96ab4619b7e3ffb096664ba01a (diff) | |
download | scala-67cf4f5e32bc036788ff7a5426a5f5c0bb07fb70.tar.gz scala-67cf4f5e32bc036788ff7a5426a5f5c0bb07fb70.tar.bz2 scala-67cf4f5e32bc036788ff7a5426a5f5c0bb07fb70.zip |
changed non-exhaustivity to attributes
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 9a8810e330..aef8f96181 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -645,8 +645,9 @@ trait Parsers requires SyntaxAnalyzer { } } - /** SimpleType ::= SimpleType TypeArgs - * | SimpleType `#' Id + /** SimpleType ::= {`@' Attribute} SimpleType1 + * SimpleType1 ::= SimpleType1 TypeArgs + * | SimpleType1 `#' Id * | StableId * | Path `.' type * | `(' Type `)' @@ -659,11 +660,7 @@ trait Parsers requires SyntaxAnalyzer { * | `{' [ArgTypePattern `,' [ArgTypePatterns [`,']]] `}' */ def simpleType(isPattern: boolean): Tree = { - val attribs = - if(settings.Xplugtypes.value) - typeAttributes - else - Nil + val attribs = typeAttributes() val pos = in.currentPos var t: Tree = @@ -707,7 +704,10 @@ trait Parsers requires SyntaxAnalyzer { done=true } - t.withAttributes(attribs) + if (settings.Xplugtypes.value) t.withAttributes(attribs) + else (t /: attribs) ((t, attr) => attr match { + case Attribute(constr, elements) => Attributed(constr, elements, t) + }) } /** TypeArgs ::= `[' ArgTypes `]' @@ -954,12 +954,10 @@ trait Parsers requires SyntaxAnalyzer { } } else if (in.token == MATCH) { t = atPos(in.skipToken()) { - val nocheck = isIdent && in.name == BANG - if (nocheck) in.nextToken() accept(LBRACE) val cases = caseClauses() accept(RBRACE) - Match(t, cases, !nocheck) + Match(t, cases) } } if ((mode & ClosureOK) != 0 && in.token == ARROW) { @@ -2159,12 +2157,19 @@ trait Parsers requires SyntaxAnalyzer { * * Type attributes may be arbitrary expressions. */ - def typeAttributes: List[Tree] = { + def typeAttributes(): List[Tree] = { val exps = new ListBuffer[Tree] - while(in.token == LBRACKET) { - accept(LBRACKET) - exps ++= argExprs - accept(RBRACKET) + if (settings.Xplugtypes.value) { + while(in.token == LBRACKET) { + accept(LBRACKET) + exps ++= argExprs + accept(RBRACKET) + } + } else { + while (in.token == AT) { + val pos = in.skipToken() + exps += attribute() + } } exps.toList } |