aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-02-14 18:39:14 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:14:08 +0100
commit5b63106448275d6cc4bb6822af33247c2521a63c (patch)
tree4313312569f2ae3f15f8cb1c763bc30c19c1eeea /test
parent9262d475e648219eb9ef4410d91621cc5f1f17cc (diff)
downloaddotty-5b63106448275d6cc4bb6822af33247c2521a63c.tar.gz
dotty-5b63106448275d6cc4bb6822af33247c2521a63c.tar.bz2
dotty-5b63106448275d6cc4bb6822af33247c2521a63c.zip
Make some tree fields lazy
Lazy fields are - the rhs field of a ValDef or DefDef - the body field of a Template These can be instantiated with Lazy instances. The scheme is such that lazy fields are completely transparent for users of the Trees API. The only downside is that the parameter used to initialize a potentially lazy field has a weak type (now it's Any, with Dotty it would be a union type of the form `T | Lazy[T]`. Therefore, the parameter cannot be recovered through pattern matching.
Diffstat (limited to 'test')
-rw-r--r--test/test/DeSugarTest.scala12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/test/DeSugarTest.scala b/test/test/DeSugarTest.scala
index 66fb70158..016ab5361 100644
--- a/test/test/DeSugarTest.scala
+++ b/test/test/DeSugarTest.scala
@@ -57,14 +57,14 @@ class DeSugarTest extends ParserTest {
cpy.SeqLiteral(tree1)(transform(elems))
case UnApply(fun, implicits, patterns) =>
cpy.UnApply(tree1)(transform(fun, Expr), transform(implicits), transform(patterns))
- case ValDef(name, tpt, rhs) =>
- cpy.ValDef(tree1)(name, transform(tpt, Type), transform(rhs))
- case DefDef(name, tparams, vparamss, tpt, rhs) =>
- cpy.DefDef(tree1)(name, transformSub(tparams), vparamss mapConserve (transformSub(_)), transform(tpt, Type), transform(rhs))
+ case tree1 @ ValDef(name, tpt, _) =>
+ cpy.ValDef(tree1)(name, transform(tpt, Type), transform(tree1.rhs))
+ case tree1 @ DefDef(name, tparams, vparamss, tpt, _) =>
+ cpy.DefDef(tree1)(name, transformSub(tparams), vparamss mapConserve (transformSub(_)), transform(tpt, Type), transform(tree1.rhs))
case tree1 @ TypeDef(name, rhs) =>
cpy.TypeDef(tree1)(name, transform(rhs, Type), transformSub(tree1.tparams))
- case Template(constr, parents, self, body) =>
- cpy.Template(tree1)(transformSub(constr), transform(parents), transformSub(self), transform(body, Expr))
+ case impl @ Template(constr, parents, self, _) =>
+ cpy.Template(tree1)(transformSub(constr), transform(parents), transformSub(self), transform(impl.body, Expr))
case Thicket(trees) =>
Thicket(flatten(trees mapConserve super.transform))
case tree1 =>