aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/transform/Erasure.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-08-16 11:55:57 +0200
committerMartin Odersky <odersky@gmail.com>2014-08-16 11:56:07 +0200
commit7d414eb69b28fa0f6855168aa7afe43a75b3f23e (patch)
treec6410e0331a0f43bde6876337db21415e0f81235 /src/dotty/tools/dotc/core/transform/Erasure.scala
parentc54cd3e0503144f362ecb000109b75a0a53b3165 (diff)
downloaddotty-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/core/transform/Erasure.scala')
-rw-r--r--src/dotty/tools/dotc/core/transform/Erasure.scala12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/transform/Erasure.scala b/src/dotty/tools/dotc/core/transform/Erasure.scala
index 41254c982..19662d22a 100644
--- a/src/dotty/tools/dotc/core/transform/Erasure.scala
+++ b/src/dotty/tools/dotc/core/transform/Erasure.scala
@@ -107,7 +107,8 @@ class Erasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wildcard
* - For T1 & T2, erasure(T1) (??)
* - For T1 | T2, the first base class in the linearization of T which is also a base class of T2
* - For a method type (Fs)scala.Unit, (|Fs|)scala.Unit.
- * - For any other method type (Fs)T, (|Fs|)|T|.
+ * - For any other uncurried method type (Fs)T, (|Fs|)|T|.
+ * - For a curried method type (Fs1)(Fs2)T, (|Fs1|,Es2)ET where (Es2)ET = |(Fs2)T|.
* - For a polymorphic type, the erasure of its result type.
* - For the class info type of java.lang.Object, the same type without any parents.
* - For a class info type of a value class, the same type without any parents.
@@ -140,8 +141,13 @@ class Erasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wildcard
this(tp.baseTypeRef(lubClass(tp1, tp2)))
case tp: MethodType =>
val paramErasure = erasureFn(tp.isJava, isSemi, isConstructor, wildcardOK)(_)
- tp.derivedMethodType(
- tp.paramNames, tp.paramTypes.mapConserve(paramErasure), eraseResult(tp.resultType))
+ val formals = tp.paramTypes.mapConserve(paramErasure)
+ eraseResult(tp.resultType) match {
+ case rt: MethodType =>
+ tp.derivedMethodType(tp.paramNames ++ rt.paramNames, formals ++ rt.paramTypes, rt.resultType)
+ case rt =>
+ tp.derivedMethodType(tp.paramNames, formals, rt)
+ }
case tp: PolyType =>
this(tp.resultType)
case tp @ ClassInfo(pre, cls, classParents, decls, _) =>