diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2013-01-29 11:38:00 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2013-02-03 21:08:33 +0100 |
commit | 6697c283af73ff82b37f50a50e93e56934d5701c (patch) | |
tree | 488b0376eb30e2359ef1c6af3b815bada9a10c4d /src/compiler | |
parent | 59918ee4dd1cd14e7d23b779fd8c9ac41d188809 (diff) | |
download | scala-6697c283af73ff82b37f50a50e93e56934d5701c.tar.gz scala-6697c283af73ff82b37f50a50e93e56934d5701c.tar.bz2 scala-6697c283af73ff82b37f50a50e93e56934d5701c.zip |
Allow for Function treess with refined types in UnCurry.
Also removes an unnecessary condition in UnCurry, isFunctionType(fun.tpe)
is always true.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/UnCurry.scala | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index f338e390bb..965063a724 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -231,7 +231,17 @@ abstract class UnCurry extends InfoTransform * If `settings.XoldPatmat.value`, also synthesized AbstractPartialFunction subclasses (see synthPartialFunction). * */ - def transformFunction(fun: Function): Tree = + def transformFunction(fun: Function): Tree = { + fun.tpe match { + // can happen when analyzer plugins assign refined types to functions, e.g. + // (() => Int) { def apply(): Int @typeConstraint } + case RefinedType(List(funTp), decls) => + debuglog(s"eliminate refinement from function type ${fun.tpe}") + fun.tpe = funTp + case _ => + () + } + deEta(fun) match { // nullary or parameterless case fun1 if fun1 ne fun => fun1 @@ -239,10 +249,7 @@ abstract class UnCurry extends InfoTransform // only get here when running under -Xoldpatmat synthPartialFunction(fun) case _ => - val parents = ( - if (isFunctionType(fun.tpe)) addSerializable(abstractFunctionForFunctionType(fun.tpe)) - else addSerializable(ObjectClass.tpe, fun.tpe) - ) + val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe)) val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation serialVersionUIDAnnotation anonClass setInfo ClassInfoType(parents, newScope, anonClass) @@ -275,6 +282,7 @@ abstract class UnCurry extends InfoTransform } } + } /** Transform a function node (x => body) of type PartialFunction[T, R] where * body = expr match { case P_i if G_i => E_i }_i=1..n |