Permalink
Browse files

Fix for exponential compile time in specialization.

Backport fix to 2.9.2, from commit 39f01d4
on paulp/scala.
Review by @prokopec.

Conflicts:
	src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
  • Loading branch information...
1 parent 949a480 commit af26e24e2bec13d12697030994b9b6440d443233 @paulp paulp committed with Blaisorblade Jul 1, 2012
@@ -1262,7 +1262,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
transformTrees(args))))
} else super.transform(tree)
- case TypeApply(Select(qual, name), targs)
+ case TypeApply(sel @ Select(qual, name), targs)
if (!specializedTypeVars(symbol.info).isEmpty && name != nme.CONSTRUCTOR) =>
debuglog("checking typeapp for rerouting: " + tree + " with sym.tpe: " + symbol.tpe + " tree.tpe: " + tree.tpe)
val qual1 = transform(qual)
@@ -1285,7 +1285,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
log("rewrote " + tree + " to " + tree1)
localTyper.typedOperator(atPos(tree.pos)(tree1)) // being polymorphic, it must be a method
- case None => super.transform(tree)
+ case None =>
+ treeCopy.TypeApply(tree, treeCopy.Select(sel, qual1, name), super.transformTrees(targs))
+ // See pos/exponential-spec.scala - can't call transform on the whole tree again.
+ // super.transform(tree)
}
case Select(Super(_, _), name) if illegalSpecializedInheritance(currentClass) =>
@@ -0,0 +1,47 @@
+// a.scala
+// Sat Jun 30 19:51:17 PDT 2012
+
+trait Exp[T]
+
+object Test {
+ def f[T](exp: Exp[T]): Exp[T] = (
+ f[T] _
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T] // 4s
+ compose f[T] // 5s
+ compose f[T] // 5s
+ compose f[T] // 6s
+ compose f[T] // 7s
+ compose f[T] // 8s
+ compose f[T] // 11s
+ compose f[T] // 17s
+ compose f[T] // 29s
+ compose f[T] // 54s
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ compose f[T]
+ )(exp)
+}

0 comments on commit af26e24

Please sign in to comment.