diff options
author | Martin Odersky <odersky@gmail.com> | 2015-02-14 18:39:14 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 11:14:08 +0100 |
commit | 5b63106448275d6cc4bb6822af33247c2521a63c (patch) | |
tree | 4313312569f2ae3f15f8cb1c763bc30c19c1eeea /src/dotty/tools/dotc/transform/RestoreScopes.scala | |
parent | 9262d475e648219eb9ef4410d91621cc5f1f17cc (diff) | |
download | dotty-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/transform/RestoreScopes.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/RestoreScopes.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/transform/RestoreScopes.scala b/src/dotty/tools/dotc/transform/RestoreScopes.scala index 5f2fd689d..8a6bb15ba 100644 --- a/src/dotty/tools/dotc/transform/RestoreScopes.scala +++ b/src/dotty/tools/dotc/transform/RestoreScopes.scala @@ -20,9 +20,9 @@ class RestoreScopes extends MiniPhaseTransform with IdentityDenotTransformer { t override def phaseName = "restoreScopes" override def transformTypeDef(tree: TypeDef)(implicit ctx: Context, info: TransformerInfo) = { - val TypeDef(_, Template(constr, _, _, body)) = tree + val TypeDef(_, impl: Template) = tree val restoredDecls = newScope - for (stat <- constr :: body) + for (stat <- impl.constr :: impl.body) if (stat.isInstanceOf[MemberDef] && stat.symbol.exists) restoredDecls.enter(stat.symbol) val cls = tree.symbol.asClass |