blob: 93ec1c937ab1e2b427e2ca43fc60cfe617a89157 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import scala.tools.partest.MemoryTest
trait A { type T <: A }
trait B { type T <: B }
object Test extends MemoryTest {
lazy val tb = {
import scala.reflect.runtime.universe._
import scala.reflect.runtime.{currentMirror => cm}
import scala.tools.reflect.ToolBox
cm.mkToolBox()
}
// I'm not sure this is a great way to test for memory leaks,
// since we're also testing how good the JVM's GC is, and this is not easily reproduced between machines/over time
override def maxDelta = 12
override def calcsPerIter = 8
override def calc() {
var snippet = """
trait A { type T <: A }
trait B { type T <: B }
def foo[T](x: List[T]) = x
foo(List(new A {}, new B {}))
""".trim
snippet = snippet + "\n" + (List.fill(50)(snippet.split("\n").last) mkString "\n")
tb.typecheck(tb.parse(snippet))
}
}
|