mirror of https://github.com/sbt/sbt.git
Test `memberRef` and `inheritance` in DependencySpecification.
Flip `memberRefAndInheritanceDeps` flag to true which allows us to
test `memberRef` and `inheritance` relations instead of `direct` and
`publicInherited` as it was previously done.
There a few changes to extracted dependencies from public members:
* F doesn't depend on C by inheritance anymore. The dependency on
C was coming from self type. This shows that dependencies from self
types are not considered to be dependencies introduces by inheritance
anymore.
* G depends on B by member reference now. This dependency is introduced
by applying type constructor `G.T` and expanding the result of the
application.
* H doesn't depend on D by inheritance anymore. That dependency was
introduced through B which inherits from D. This shows that only
parents (and not all base classes) are included in `inheritance`
relation.
NOTE: The second bullet highlights a bug in the old dependency tracking
logic. The dependency on B was recorded in `publicInherited` but not in
`direct` relation. This breaks the contract which says that
`publicInherited` is a subset of `direct` relation.
This a change to dependencies extracted from non-public members:
* C depends on A by inheritance and D depends on B by inheritance now;
both changes are of the same kind: dependencies introduced by
inheritance are tracked for non-public members now. This is necessary
for name hashing correctness algorithm
This commit is contained in:
parent
533a5b8c23
commit
2226fccd4f
|
|
@ -27,10 +27,10 @@ class DependencySpecification extends Specification {
|
|||
memberRef('E) === Set.empty
|
||||
inheritance('E) === Set.empty
|
||||
memberRef('F) === Set('A, 'B, 'C, 'D, 'E)
|
||||
inheritance('F) === Set('A, 'C, 'E)
|
||||
memberRef('H) === Set('G, 'E)
|
||||
inheritance('F) === Set('A, 'E)
|
||||
memberRef('H) === Set('B, 'E, 'G)
|
||||
// aliases and applied type constructors are expanded so we have inheritance dependency on B
|
||||
inheritance('H) === Set('D, 'E, 'B)
|
||||
inheritance('H) === Set('B, 'E)
|
||||
}
|
||||
|
||||
"Extracted source dependencies from private members" in {
|
||||
|
|
@ -42,9 +42,9 @@ class DependencySpecification extends Specification {
|
|||
memberRef('B) === Set.empty
|
||||
inheritance('B) === Set.empty
|
||||
memberRef('C) === Set('A)
|
||||
inheritance('C) === Set.empty
|
||||
inheritance('C) === Set('A)
|
||||
memberRef('D) === Set('B)
|
||||
inheritance('D) === Set.empty
|
||||
inheritance('D) === Set('B)
|
||||
}
|
||||
|
||||
private def extractSourceDependenciesPublic: ExtractedSourceDependencies = {
|
||||
|
|
@ -62,7 +62,7 @@ class DependencySpecification extends Specification {
|
|||
// E verifies the core type gets pulled out
|
||||
val srcH = "trait H extends G.T[Int] with (E[Int] @unchecked)"
|
||||
|
||||
val compilerForTesting = new ScalaCompilerForUnitTesting(memberRefAndInheritanceDeps = false)
|
||||
val compilerForTesting = new ScalaCompilerForUnitTesting(memberRefAndInheritanceDeps = true)
|
||||
val sourceDependencies = compilerForTesting.extractDependenciesFromSrcs('A -> srcA, 'B -> srcB, 'C -> srcC,
|
||||
'D -> srcD, 'E -> srcE, 'F -> srcF, 'G -> srcG, 'H -> srcH)
|
||||
sourceDependencies
|
||||
|
|
@ -74,7 +74,7 @@ class DependencySpecification extends Specification {
|
|||
val srcC = "class C { private class Inner1 extends A }"
|
||||
val srcD = "class D { def foo: Unit = { class Inner2 extends B } }"
|
||||
|
||||
val compilerForTesting = new ScalaCompilerForUnitTesting(memberRefAndInheritanceDeps = false)
|
||||
val compilerForTesting = new ScalaCompilerForUnitTesting(memberRefAndInheritanceDeps = true)
|
||||
val sourceDependencies =
|
||||
compilerForTesting.extractDependenciesFromSrcs('A -> srcA, 'B -> srcB, 'C -> srcC, 'D -> srcD)
|
||||
sourceDependencies
|
||||
|
|
|
|||
Loading…
Reference in New Issue