summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/matching/CodeFactory.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/matching/CodeFactory.scala')
-rw-r--r--src/compiler/scala/tools/nsc/matching/CodeFactory.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala
index 8494b9e4bf..13472a8d19 100644
--- a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala
+++ b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala
@@ -80,6 +80,12 @@ trait CodeFactory {
result
}
+ def makeIf(cond:Tree, thenp:Tree, elsep:Tree) = cond match {
+ case Literal(Constant(true)) => thenp
+ case Literal(Constant(false)) => elsep
+ case _ => If(cond, thenp, elsep)
+ }
+
/** returns code `<seqObj>.elements' */
def newIterator(seqObj: Tree): Tree =
Apply(Select(seqObj, newTermName("elements")), List())