Skip to content

Commit 0443294

Browse files
authored
Merge pull request #16 from francesconero/fix-slow-scala2-compilation-2
Fix slow Scala2 subtype check for long twiddles
2 parents 696f890 + 743f984 commit 0443294

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

core/jvm/src/test/scala-2/org/typelevel/twiddles/test/CompilationPerformanceSpec.scala

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,36 @@ class CompilationPerformanceSpec extends FunSuite {
6161
assert(compiled.isInstanceOf[Tuple])
6262
}
6363

64+
test("should subtype in a reasonable amount of time") {
65+
val compiled = compileWithin(
66+
q"""import org.typelevel.twiddles._
67+
val inferred =
68+
1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *:
69+
1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *:
70+
1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *:
71+
1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *:
72+
1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *:
73+
1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *:
74+
1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *:
75+
1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *: 1 *:
76+
EmptyTuple
77+
type Expected =
78+
Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *:
79+
Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *:
80+
Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *:
81+
Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *:
82+
Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *:
83+
Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *:
84+
Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *:
85+
Int *: Int *: Int *: Int *: Int *: Int *: Int *: Int *:
86+
EmptyTuple
87+
inferred: Expected""",
88+
10.seconds
89+
)
90+
91+
assert(compiled.isInstanceOf[Tuple])
92+
}
93+
6494
private val toolbox = {
6595
val toolbox = currentMirror.mkToolBox()
6696
// warmup

core/shared/src/main/scala-2/org/typelevel/twiddles/TwiddleCompat.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ trait TwiddleCompat {
4242
type EmptyTuple = HNil
4343
@inline val EmptyTuple: EmptyTuple = HNil
4444

45-
type *:[A, B <: Tuple] = ::[A, B]
45+
type *:[+A, +B <: Tuple] = ::[A, B]
4646
@inline val *: = ::
4747

4848
implicit def toTupleOps[T <: Tuple](t: T): TupleOps[T] =

0 commit comments

Comments
 (0)