Skip to content

Commit af26e24

Browse files
paulpBlaisorblade
authored andcommitted
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
1 parent 949a480 commit af26e24

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
12621262
transformTrees(args))))
12631263
} else super.transform(tree)
12641264

1265-
case TypeApply(Select(qual, name), targs)
1265+
case TypeApply(sel @ Select(qual, name), targs)
12661266
if (!specializedTypeVars(symbol.info).isEmpty && name != nme.CONSTRUCTOR) =>
12671267
debuglog("checking typeapp for rerouting: " + tree + " with sym.tpe: " + symbol.tpe + " tree.tpe: " + tree.tpe)
12681268
val qual1 = transform(qual)
@@ -1285,7 +1285,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
12851285
log("rewrote " + tree + " to " + tree1)
12861286
localTyper.typedOperator(atPos(tree.pos)(tree1)) // being polymorphic, it must be a method
12871287

1288-
case None => super.transform(tree)
1288+
case None =>
1289+
treeCopy.TypeApply(tree, treeCopy.Select(sel, qual1, name), super.transformTrees(targs))
1290+
// See pos/exponential-spec.scala - can't call transform on the whole tree again.
1291+
// super.transform(tree)
12891292
}
12901293

12911294
case Select(Super(_, _), name) if illegalSpecializedInheritance(currentClass) =>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// a.scala
2+
// Sat Jun 30 19:51:17 PDT 2012
3+
4+
trait Exp[T]
5+
6+
object Test {
7+
def f[T](exp: Exp[T]): Exp[T] = (
8+
f[T] _
9+
compose f[T]
10+
compose f[T]
11+
compose f[T]
12+
compose f[T]
13+
compose f[T]
14+
compose f[T]
15+
compose f[T]
16+
compose f[T]
17+
compose f[T]
18+
compose f[T] // 4s
19+
compose f[T] // 5s
20+
compose f[T] // 5s
21+
compose f[T] // 6s
22+
compose f[T] // 7s
23+
compose f[T] // 8s
24+
compose f[T] // 11s
25+
compose f[T] // 17s
26+
compose f[T] // 29s
27+
compose f[T] // 54s
28+
compose f[T]
29+
compose f[T]
30+
compose f[T]
31+
compose f[T]
32+
compose f[T]
33+
compose f[T]
34+
compose f[T]
35+
compose f[T]
36+
compose f[T]
37+
compose f[T]
38+
compose f[T]
39+
compose f[T]
40+
compose f[T]
41+
compose f[T]
42+
compose f[T]
43+
compose f[T]
44+
compose f[T]
45+
compose f[T]
46+
)(exp)
47+
}

0 commit comments

Comments
 (0)