Code used for the the following examples.
val tree =
q"""
val a = 5
val c = 3
c = 5
if (3 == 17) {
val c = 1
}
val a = 5 | |
val c = 3 | |
c = 5 | |
if (3 == 17) { | |
val c = { | |
val d = "hey" | |
22 | |
} | |
} | |
else |
def apply = (focus{case _: Defn.Def => true} andThen | |
collect[Set]{ | |
case Term.Assign(b: Term.Name, _) => b | |
}.topDown feed { assigns => | |
transform{ | |
case t @ Defn.Var(a, (b: Term.Name) :: Nil, c, Some(d)) if !assigns.contains(b) => | |
Defn.Val(a, b :: Nil, c, d) andCollect message(b, t) | |
}.topDown | |
} | |
).topDownBreak |
(collect { | |
case t @ Defn.Val(_, _, None, _) => | |
message(t, t.getType) | |
case t @ Defn.Def(_, _, _, _, None, _) => | |
message(t, t.getType) | |
} <~ | |
update { | |
case t @ Defn.Val(mods, pats, None, rhs) => | |
Defn.Val(mods, pats, Some(t.getType), rhs) | |
} + |
import scala.reflect.ClassTag | |
trait AllowedTransfomation[I, O] | |
trait ToType[A, B] | |
trait Monoid[A]{ | |
def zero : A | |
def append(a: A, b: A): A | |
} |
import scala.reflect.ClassTag | |
trait AllowedTransfomation[I, O] | |
trait ToType[A, B] | |
trait Monoid[A]{ | |
def zero : A | |
def append(a: A, b: A): A | |
} |
Code used for the the following examples.
val tree =
q"""
val a = 5
val c = 3
c = 5
if (3 == 17) {
val c = 1
}
import org.scalameter._ | |
import org.scalameter.execution.LocalExecutor | |
import org.scalameter.reporting.LoggingReporter | |
object SwitchBenchmark extends PerformanceTest { | |
lazy val executor = LocalExecutor( | |
new Executor.Warmer.Default, |
... | |
InvariantSuite: | |
- more informative error messages *** FAILED *** | |
"...that x.>(3) is false[] | |
where x = 2" did not equal "...that x.>(3) is false[ | |
where x = 2" (InvariantSuite.scala:12) | |
ShowSuite: | |
... | |
- string literals with newlines and double quotes *** FAILED *** | |
"... None, Lit.String("\[r\n x\r]\n ")), Defn.Va..." did no |
AdtSuite: | |
ReflectionSuite: | |
- root | |
- If | |
- Term.Name | |
LitSuite: | |
- true | |
- false | |
- 42 | |
- 42L |
val collectDef = | |
collectIn[Set]{ | |
case t: Defn.Def if(!ignore(t)) => t.getName | |
}.down feed {defs => | |
collect{ | |
case Term.Assign(b: Term.Name, _) if(defs.contains(b)) => warning(b) | |
}.down | |
} | |