summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Shabalin <denys.shabalin@typesafe.com>2014-02-28 14:38:31 +0100
committerDenys Shabalin <denys.shabalin@typesafe.com>2014-03-09 15:47:26 +0200
commit1b5a34b402cb283db6029a1d54778390ba14ef6f (patch)
treea95fada473ac1a64cd1579b58741835cb8196419
parent67d175f06db62e8af18851fc5694cfff2158d73b (diff)
downloadscala-1b5a34b402cb283db6029a1d54778390ba14ef6f.tar.gz
scala-1b5a34b402cb283db6029a1d54778390ba14ef6f.tar.bz2
scala-1b5a34b402cb283db6029a1d54778390ba14ef6f.zip
Address pull request feedback
1. Tighten up the if else to avoid duplication 2. Add doc comments
-rw-r--r--src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala6
-rw-r--r--src/reflect/scala/reflect/internal/ReificationSupport.scala14
2 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
index ebb59f98fd..c37d5a3273 100644
--- a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
+++ b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
@@ -218,10 +218,8 @@ trait Reifiers { self: Quasiquotes =>
case Select(id @ Ident(nme.scala_), name) if id.symbol == ScalaPackage =>
reifyBuildCall(nme.ScalaDot, name)
case Select(qual, name) =>
- if (name.isTypeName)
- reifyBuildCall(nme.SyntacticSelectType, qual, name)
- else
- reifyBuildCall(nme.SyntacticSelectTerm, qual, name)
+ val ctor = if (name.isTypeName) nme.SyntacticSelectType else nme.SyntacticSelectTerm
+ reifyBuildCall(ctor, qual, name)
case _ =>
super.reifyTreeSyntactically(tree)
}
diff --git a/src/reflect/scala/reflect/internal/ReificationSupport.scala b/src/reflect/scala/reflect/internal/ReificationSupport.scala
index 9a47bab37c..dfe1811ff0 100644
--- a/src/reflect/scala/reflect/internal/ReificationSupport.scala
+++ b/src/reflect/scala/reflect/internal/ReificationSupport.scala
@@ -201,6 +201,9 @@ trait ReificationSupport { self: SymbolTable =>
def unapply(flags: Long): Some[Long] = Some(flags)
}
+ /** Construct/deconstruct type application term trees.
+ * Treats other term trees as zero-argument type applications.
+ */
object SyntacticTypeApplied extends SyntacticTypeAppliedExtractor {
def apply(tree: Tree, targs: List[Tree]): Tree =
if (targs.isEmpty) tree
@@ -214,6 +217,9 @@ trait ReificationSupport { self: SymbolTable =>
}
}
+ /** Construct/deconstruct applied type trees.
+ * Treats other types as zero-arity applied types.
+ */
object SyntacticAppliedType extends SyntacticTypeAppliedExtractor {
def apply(tree: Tree, targs: List[Tree]): Tree =
if (targs.isEmpty) tree
@@ -235,10 +241,10 @@ trait ReificationSupport { self: SymbolTable =>
case UnApply(treeInfo.Unapplied(Select(fun, nme.unapply)), pats) =>
Some((fun, pats :: Nil))
case treeInfo.Applied(fun, targs, argss) =>
- if (fun.isTerm)
- Some((SyntacticTypeApplied(fun, targs), argss))
- else
- Some((SyntacticAppliedType(fun, targs), argss))
+ val callee =
+ if (fun.isTerm) SyntacticTypeApplied(fun, targs)
+ else SyntacticAppliedType(fun, targs)
+ Some((callee, argss))
}
}