Create TypedTreeMap that propagates types

If some node in tree is transformed changing the type,
the outer node could potentially also change type.

This patch implements a TypedTreeMap that propagates those
changes until types converge. Propagation is done for tree nodes
that are able to compute their type based on their children:
Pair, Block, If, Match, CaseDef, Try, SeqLiteral, Annotated

Note: patch doesn't cover Select's, see #143 for the issue
with Select.
OK, I see the reasoning. It should not matter because annot is summarized
by annot.tpe, but it makes sense to not take account of that argument on
the level of RetypingTreeMap.


On Mon, Jul 21, 2014 at 11:13 PM, Dmitry Petrashko <notifications@github.com
> wrote:

> In src/dotty/tools/dotc/ast/tpd.scala:
>
> > +    else ta.assignType(newTree, newTree.body)
> > +  }
> > +
> > +  def propagateType(origTree: Try, newTree: Try)(implicit ctx: Context) = {
> > +    if ((newTree eq origTree) ||
> > +      ((newTree.expr.tpe eq origTree.expr.tpe) && (newTree.handler.tpe eq origTree.handler.tpe))) newTree
> > +    else ta.assignType(newTree, newTree.expr, newTree.handler)
> > +  }
> > +
> > +  def propagateType(origTree: SeqLiteral, newTree: SeqLiteral)(implicit ctx: Context) = {
> > +    if ((newTree eq origTree) || ctx.erasedTypes || sameTypes(newTree.elems, origTree.elems)) newTree
> > +    else ta.assignType(newTree, newTree.elems)
> > +  }
> > +
> > +  def propagateType(origTree: Annotated, newTree: Annotated)(implicit ctx: Context) = {
> > +    if ((newTree eq origTree) || ((newTree.arg.tpe eq origTree.arg.tpe) && (newTree.annot eq origTree.annot))) newTree
>
> Yes, It would yield a different tree, but would carry over it's type in
> postProcess from the old one. And in case arg.tpe did not change but annot(not
> even the type!) did there could be a wrong carried over type.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/lampepfl/dotty/pull/144/files#r15196827>.
>



-- 
Martin Odersky
EPFL