mirror of https://github.com/sbt/sbt.git
Add a pending test for a modified member of a trait
The test shows that name hashing optimization is broken for members
defined in traits. The problem is that modification of a member of a trait
triggers change of a hash of trait's name.
The behavior covered by this test regressed in
40ebc82531
The bug is tracked in #2436.
This commit is contained in:
parent
14dcca6a31
commit
0ceb79cff4
|
|
@ -0,0 +1,27 @@
|
||||||
|
/* Performs checks related to compilations:
|
||||||
|
* a) checks in which compilation given set of files was recompiled
|
||||||
|
* b) checks overall number of compilations performed
|
||||||
|
*/
|
||||||
|
TaskKey[Unit]("check-compilations") := {
|
||||||
|
val analysis = (compile in Compile).value
|
||||||
|
val srcDir = (scalaSource in Compile).value
|
||||||
|
def relative(f: java.io.File): java.io.File = f.relativeTo(srcDir) getOrElse f
|
||||||
|
val allCompilations = analysis.compilations.allCompilations
|
||||||
|
val recompiledFiles: Seq[Set[java.io.File]] = allCompilations map { c =>
|
||||||
|
val recompiledFiles = analysis.apis.internal.collect {
|
||||||
|
case (file, api) if api.compilation.startTime == c.startTime => relative(file)
|
||||||
|
}
|
||||||
|
recompiledFiles.toSet
|
||||||
|
}
|
||||||
|
def recompiledFilesInIteration(iteration: Int, fileNames: Set[String]) = {
|
||||||
|
val files = fileNames.map(new java.io.File(_))
|
||||||
|
assert(recompiledFiles(iteration) == files, "%s != %s".format(recompiledFiles(iteration), files))
|
||||||
|
}
|
||||||
|
assert(allCompilations.size == 2)
|
||||||
|
// B.scala is just compiled at the beginning
|
||||||
|
recompiledFilesInIteration(0, Set("B.scala"))
|
||||||
|
// A.scala is changed and recompiled
|
||||||
|
recompiledFilesInIteration(1, Set("A.scala"))
|
||||||
|
}
|
||||||
|
|
||||||
|
logLevel := Level.Debug
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
trait A {
|
||||||
|
def foo: Int = 12
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Test if adding a member to a trait affects classes that refer to that trait
|
||||||
|
# by a member reference
|
||||||
|
> compile
|
||||||
|
# add `foo` method to `A`
|
||||||
|
$ copy-file changes/A1.scala src/main/scala/A.scala
|
||||||
|
# only A.scala should be recompiled
|
||||||
|
> compile
|
||||||
|
# check if there are only two compile iterations performed
|
||||||
|
> check-compilations
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
trait A
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
class B(a: A)
|
||||||
Loading…
Reference in New Issue