summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-09-05 20:41:48 +0200
committerDen Shabalin <den.shabalin@gmail.com>2013-09-05 20:42:10 +0200
commit546e94099d667c6395582fcba321ef95578121a5 (patch)
tree6c250294e163c0aa008d117b5e994003174857fe /src/compiler
parent1352fea1c4ecfa0fd66ff1d5ad6e0ee437b1a59f (diff)
downloadscala-546e94099d667c6395582fcba321ef95578121a5.tar.gz
scala-546e94099d667c6395582fcba321ef95578121a5.tar.bz2
scala-546e94099d667c6395582fcba321ef95578121a5.zip
SI-7803 support for matching of anonymous function literals
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala4
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala5
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala5
3 files changed, 12 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index f52ed60480..70b32f08ae 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1445,7 +1445,7 @@ self =>
// The case still missed is unparenthesized single argument, like "x: Int => x + 1", which
// may be impossible to distinguish from a self-type and so remains an error. (See #1564)
def lhsIsTypedParamList() = t match {
- case Parens(xs) if xs forall (_.isInstanceOf[Typed]) => true
+ case Parens(xs) if xs.forall(isTypedParam) => true
case _ => false
}
if (in.token == ARROW && (location != InTemplate || lhsIsTypedParamList)) {
@@ -1458,6 +1458,8 @@ self =>
parseOther
}
+ def isTypedParam(t: Tree) = t.isInstanceOf[Typed]
+
/** {{{
* Expr ::= implicit Id => Expr
* }}}
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
index 868c74ebcd..19888fa8d2 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Parsers.scala
@@ -135,6 +135,11 @@ trait Parsers { self: Quasiquotes =>
case Ident(name: TermName) if isHole(name) => ValDef(NoMods | Flag.PRESUPER, name, Ident(tpnme.QUASIQUOTE_EARLY_DEF), EmptyTree)
case _ => super.ensureEarlyDef(tree)
}
+
+ override def isTypedParam(tree: Tree) = super.isTypedParam(tree) || (tree match {
+ case Ident(name) if isHole(name) => true
+ case _ => false
+ })
}
}
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
index 53b2e4cc96..fa305f3d07 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
@@ -8,7 +8,8 @@ import scala.reflect.internal.Flags._
trait Reifiers { self: Quasiquotes =>
import global._
import global.build.{SyntacticClassDef, SyntacticTraitDef, SyntacticModuleDef,
- SyntacticBlock, SyntacticApplied, SyntacticTypeApplied}
+ SyntacticBlock, SyntacticApplied, SyntacticTypeApplied,
+ SyntacticFunction}
import global.treeInfo._
import global.definitions._
import Cardinality._
@@ -67,6 +68,8 @@ trait Reifiers { self: Quasiquotes =>
reifyBuildCall(nme.SyntacticApplied, fun, argss)
case SyntacticTypeApplied(fun, targs) if targs.nonEmpty =>
reifyBuildCall(nme.SyntacticTypeApplied, fun, targs)
+ case SyntacticFunction(args, body) =>
+ reifyBuildCall(nme.SyntacticFunction, args, body)
case Block(stats, last) =>
reifyBuildCall(nme.SyntacticBlock, stats :+ last)
// parser emits trees with scala package symbol to ensure