summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2010-10-16 14:41:48 +0000
committerMartin Odersky <odersky@gmail.com>2010-10-16 14:41:48 +0000
commit30872339677177693b988f31fae5fe660289b3e2 (patch)
tree5d7e3110e1ebf733230582f8e890cf5b0a433599 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
parent1e73d82e13161ffed415118cee8530a1ac6ad688 (diff)
downloadscala-30872339677177693b988f31fae5fe660289b3e2.tar.gz
scala-30872339677177693b988f31fae5fe660289b3e2.tar.bz2
scala-30872339677177693b988f31fae5fe660289b3e2.zip
Closes #3672. Review by extempore.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 997573f7f5..504705c96a 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -894,6 +894,9 @@ self =>
infixTypeRest(compoundType(isPattern), isPattern, mode)
}
+ def typeOrInfixType(location: Int): Tree =
+ if (location == Local) typ() else infixType(false, InfixMode.FirstOp)
+
def infixTypeRest(t: Tree, isPattern: Boolean, mode: InfixMode.Value): Tree = {
if (isIdent && in.name != nme.STAR) {
val opOffset = in.offset
@@ -1197,8 +1200,7 @@ self =>
t = (t /: annotations(false, false)) (makeAnnotated)
} else {
t = atPos(t.pos.startOrPoint, colonPos) {
- val tpt =
- if (location == Local) typ() else infixType(false, InfixMode.FirstOp)
+ val tpt = typeOrInfixType(location)
if (isWildcard(t))
(placeholderParams: @unchecked) match {
case (vd @ ValDef(mods, name, _, _)) :: rest =>
@@ -1237,7 +1239,16 @@ self =>
/** Expr ::= implicit Id => Expr
*/
def implicitClosure(start: Int, location: Int): Tree = {
- val param0 = convertToParam(atPos(in.offset)(Ident(ident())))
+ val param0 = convertToParam {
+ atPos(in.offset) {
+ var paramexpr: Tree = Ident(ident())
+ if (in.token == COLON) {
+ in.nextToken()
+ paramexpr = Typed(paramexpr, typeOrInfixType(location))
+ }
+ paramexpr
+ }
+ }
val param = treeCopy.ValDef(param0, param0.mods | Flags.IMPLICIT, param0.name, param0.tpt, param0.rhs)
atPos(start, in.offset) {
accept(ARROW)