diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-11 11:34:08 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-11 11:34:08 +0100 |
commit | c8f71771b648cf4482a0ee79a31dff75fd9bcf48 (patch) | |
tree | f066cedf4bb9ec7a6b49bb0967d42f8daa0f4282 /src | |
parent | 382e04d4b8a42c0d0c30d4faae623c9d213e5336 (diff) | |
download | dotty-c8f71771b648cf4482a0ee79a31dff75fd9bcf48.tar.gz dotty-c8f71771b648cf4482a0ee79a31dff75fd9bcf48.tar.bz2 dotty-c8f71771b648cf4482a0ee79a31dff75fd9bcf48.zip |
Fixes to lifting in eta-expansion
1. Lifted defs should not get expr or singleton types of the lifted value. Need to widen.
2. In op-assignments we need to lift the prefix of the lhs function, not the function itself.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/typer/EtaExpansion.scala | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala index cb8c5a43a..26a2af231 100644 --- a/src/dotty/tools/dotc/typer/EtaExpansion.scala +++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala @@ -24,18 +24,18 @@ object EtaExpansion { if (isIdempotentExpr(expr)) expr else { val name = ctx.freshName(prefix).toTermName - val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, expr.tpe, coord = positionCoord(expr.pos)) + val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, expr.tpe.widen, coord = positionCoord(expr.pos)) defs += ValDef(sym, expr) Ident(sym.valRef) } - /** Lift out common part of tree taking part in an operator assignment such as + /** Lift out common part of lhs tree taking part in an operator assignment such as * - * tree += expr + * lhs += expr */ def liftAssigned(defs: mutable.ListBuffer[Tree], tree: Tree)(implicit ctx: Context): Tree = tree match { - case Apply(fn, args) => - cpy.Apply(tree, lift(defs, fn), liftArgs(defs, fn.tpe, args)) + case Apply(fn @ Select(pre, name), args) => + cpy.Apply(tree, cpy.Select(fn, lift(defs, pre), name), liftArgs(defs, fn.tpe, args)) case Select(pre, name) => cpy.Select(tree, lift(defs, pre), name) case _ => |