Skip to content

Commit 39f01d4

Browse files
committed
Fix for exponential compile time in specialization.
Review by @Prokopec.
1 parent 0a9cea6 commit 39f01d4

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
@@ -1366,7 +1366,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
13661366

13671367
override def transform(tree: Tree): Tree =
13681368
reportError { transform1(tree) } {_ => tree}
1369-
1369+
13701370
def transform1(tree: Tree) = {
13711371
val symbol = tree.symbol
13721372

@@ -1437,7 +1437,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
14371437
localTyper.typedOperator(atPos(tree.pos)(tree1)) // being polymorphic, it must be a method
14381438
}
14391439

1440-
case None => super.transform(tree)
1440+
case None =>
1441+
treeCopy.TypeApply(tree, treeCopy.Select(sel, qual1, name), super.transformTrees(targs))
1442+
// See pos/exponential-spec.scala - can't call transform on the whole tree again.
1443+
// super.transform(tree)
14411444
}
14421445

14431446
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)