Skip to content
This repository has been archived by the owner on Apr 19, 2020. It is now read-only.

Commit

Permalink
Address pull request feedback
Browse files Browse the repository at this point in the history
1. Tighten up the if else to avoid duplication
2. Add doc comments
  • Loading branch information
densh committed Mar 9, 2014
1 parent 67d175f commit 1b5a34b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
14 changes: 10 additions & 4 deletions src/reflect/scala/reflect/internal/ReificationSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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))
}
}

Expand Down

0 comments on commit 1b5a34b

Please sign in to comment.