diff options
author | Martin Odersky <odersky@gmail.com> | 2014-08-16 11:55:57 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-08-16 11:56:07 +0200 |
commit | 7d414eb69b28fa0f6855168aa7afe43a75b3f23e (patch) | |
tree | c6410e0331a0f43bde6876337db21415e0f81235 /src/dotty/tools/dotc/transform/UncurryTreeTransform.scala | |
parent | c54cd3e0503144f362ecb000109b75a0a53b3165 (diff) | |
download | dotty-7d414eb69b28fa0f6855168aa7afe43a75b3f23e.tar.gz dotty-7d414eb69b28fa0f6855168aa7afe43a75b3f23e.tar.bz2 dotty-7d414eb69b28fa0f6855168aa7afe43a75b3f23e.zip |
Roll Uncurry into Erasure
Making cpy recompute types uncovered errors in uncurry. In a nutshell,
the intermediate Apply nodes of a curried function were ill-typed, which
caused errors produced by TypeAssigner. These nodes were eliminated down the
road, but the errors are already issued.
I did not find a good way to treat uncurry as a treetransform. Since it is rather
trivial, it did not seem warranted to make it a full transformer either. So in
the end the uncurry functionality became part of erasure.
Diffstat (limited to 'src/dotty/tools/dotc/transform/UncurryTreeTransform.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/UncurryTreeTransform.scala | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/src/dotty/tools/dotc/transform/UncurryTreeTransform.scala b/src/dotty/tools/dotc/transform/UncurryTreeTransform.scala deleted file mode 100644 index cf7668079..000000000 --- a/src/dotty/tools/dotc/transform/UncurryTreeTransform.scala +++ /dev/null @@ -1,46 +0,0 @@ -package dotty.tools.dotc -package transform - -import TreeTransforms._ -import core.DenotTransformers._ -import core.Denotations._ -import core.SymDenotations._ -import core.Contexts._ -import core.Types._ -import core.Symbols._ -import ast.Trees._ -import ast.tpd.{Apply, Tree, cpy} - -class UncurryTreeTransform extends MiniPhaseTransform with InfoTransformer { - - override def name: String = "uncurry" - override def transformApply(tree: Apply)(implicit ctx: Context, info: TransformerInfo): Tree = - ctx.traceIndented(s"transforming ${tree.show}", show = true) { - tree.fun match { - case Apply(fn, args) => - def showType(implicit ctx: Context) = - ctx.log(s"at ${ctx.phase} ${fn.symbol} has type ${fn.symbol.info.widen.show}") - showType - ctx.atNextPhase(showType(_)) - showType - cpy.Apply(tree)(tree.fun, args ++ tree.args) - case _ => tree - }} - - def uncurry(tp: Type)(implicit ctx: Context): Type = tp match { - case tp @ MethodType(pnames1, ptypes1) => - tp.resultType match { - case rt @ MethodType(pnames2, ptypes2) => - tp.derivedMethodType(pnames1 ++ pnames2, ptypes1 ++ ptypes2, rt.resultType) - case _ => - tp - } - case tp: PolyType => - tp.derivedPolyType(tp.paramNames, tp.paramBounds, uncurry(tp.resultType)) - case _ => - tp - } - - def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = - uncurry(tp) -}
\ No newline at end of file |