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:
Grzegorz Kossakowski 2016-02-02 16:37:19 +01:00 committed by Martin Duhem
parent 3c839ff3d3
commit 07ff2d8e26
5 changed files with 41 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,3 @@
trait A {
def foo: Int = 12
}

View File

@ -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

View File

@ -0,0 +1 @@
class B(a: A)