Skip to content

Commit

Permalink
Fix for exponential compile time in specialization.
Browse files Browse the repository at this point in the history
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
paulp authored and Blaisorblade committed Jul 2, 2012
1 parent 949a480 commit af26e24
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
Expand Up @@ -1262,7 +1262,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
transformTrees(args)))) transformTrees(args))))
} else super.transform(tree) } 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) => if (!specializedTypeVars(symbol.info).isEmpty && name != nme.CONSTRUCTOR) =>
debuglog("checking typeapp for rerouting: " + tree + " with sym.tpe: " + symbol.tpe + " tree.tpe: " + tree.tpe) debuglog("checking typeapp for rerouting: " + tree + " with sym.tpe: " + symbol.tpe + " tree.tpe: " + tree.tpe)
val qual1 = transform(qual) val qual1 = transform(qual)
Expand All @@ -1285,7 +1285,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
log("rewrote " + tree + " to " + tree1) log("rewrote " + tree + " to " + tree1)
localTyper.typedOperator(atPos(tree.pos)(tree1)) // being polymorphic, it must be a method 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) => case Select(Super(_, _), name) if illegalSpecializedInheritance(currentClass) =>
Expand Down
47 changes: 47 additions & 0 deletions test/files/pos/exponential-spec.scala
@@ -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.