aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/Desugar.scala
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 /src/dotty/tools/dotc/ast/Desugar.scala
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 'src/dotty/tools/dotc/ast/Desugar.scala')
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index cd198818a..60ca45f28 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -218,7 +218,7 @@ object desugar {
/** The expansion of a class definition. See inline comments for what is involved */
def classDef(cdef: TypeDef)(implicit ctx: Context): Tree = {
- val TypeDef(name, impl @ Template(constr0, parents, self, body)) = cdef
+ val TypeDef(name, impl @ Template(constr0, parents, self, _)) = cdef
val mods = cdef.mods
val (constr1, defaultGetters) = defDef(constr0, isPrimaryConstructor = true) match {
@@ -242,7 +242,7 @@ object desugar {
val constr = cpy.DefDef(constr1)(tparams = constrTparams, vparamss = constrVparamss)
// Add constructor type parameters to auxiliary constructors
- val normalizedBody = body map {
+ val normalizedBody = impl.body map {
case ddef: DefDef if ddef.name.isConstructorName =>
cpy.DefDef(ddef)(tparams = constrTparams)
case stat =>
@@ -425,10 +425,10 @@ object desugar {
val modul = ValDef(name, clsRef, New(clsRef, Nil))
.withMods(mods | ModuleCreationFlags)
.withPos(mdef.pos)
- val ValDef(selfName, selfTpt, selfRhs) = tmpl.self
+ val ValDef(selfName, selfTpt, _) = tmpl.self
val selfMods = tmpl.self.mods
if (!selfTpt.isEmpty) ctx.error("object definition may not have a self type", tmpl.self.pos)
- val clsSelf = ValDef(selfName, SingletonTypeTree(Ident(name)), selfRhs)
+ val clsSelf = ValDef(selfName, SingletonTypeTree(Ident(name)), tmpl.self.rhs)
.withMods(selfMods)
.withPos(tmpl.self.pos orElse tmpl.pos.startPos)
val clsTmpl = cpy.Template(tmpl)(self = clsSelf, body = tmpl.body)