Skip to content

Commit

Permalink
Merge pull request #1284 from Friendseeker/trait-class-bug-fix
Browse files Browse the repository at this point in the history
Include extra invalidations in initial validation to fix initial compilation error
  • Loading branch information
eed3si9n authored Nov 18, 2023
2 parents a2a3935 + f0208b6 commit 94c0b0c
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,14 @@ private[inc] abstract class IncrementalCommon(
val removedClasses = classNames(removedSrcs)
val dependentOnRemovedClasses = removedClasses.flatMap(previous.memberRef.internal.reverse)
val modifiedClasses = classNames(modifiedSrcs)
val invalidatedClasses = removedClasses ++ dependentOnRemovedClasses ++ modifiedClasses
val mutualDependentOnModifiedClasses = {
val dependentOnModifiedClasses = modifiedClasses.flatMap(previous.memberRef.internal.reverse)
dependentOnModifiedClasses.filter(dependent =>
previous.memberRef.internal.reverse(dependent).exists(modifiedClasses)
)
}
val invalidatedClasses =
removedClasses ++ dependentOnRemovedClasses ++ modifiedClasses ++ mutualDependentOnModifiedClasses

val byProduct = changes.removedProducts.flatMap(previous.produced)
val byLibraryDep = changes.libraryDeps.flatMap(previous.usesLibrary)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
abstract class A
object Test {
new B
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class B extends A
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
trait A
object Test {
new B
}
5 changes: 5 additions & 0 deletions zinc/src/sbt-test/source-dependencies/false-error/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
> compile

$ copy-file changes/A.scala A.scala

> compile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
$ copy-file changes/Providers.scala Providers.scala
$ copy-file changes/Bar.scala Bar.scala

-> compile # This should compile
> compile # This should compile
> clean
> compile # Make sure that clean compile is fine
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class Before
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Problem(wrapper: Wrapper) {
def x = wrapper.x
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ProblemUser {
val y: Seq[Before] = ???

private def method(p: Problem): Unit = {
println(p.x)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Wrapper {
def x: Before = new Before
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class After
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ProblemUser {
val y: Seq[After] = ???

private def method(p: Problem): Unit = {
println(p.x)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Wrapper {
def x: After = new After
}
7 changes: 7 additions & 0 deletions zinc/src/sbt-test/source-dependencies/no-type-annotation/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
> compile

$ copy-file changes/Before.scala Before.scala
$ copy-file changes/ProblemUser.scala ProblemUser.scala
$ copy-file changes/Wrapper.scala Wrapper.scala

> compile

0 comments on commit 94c0b0c

Please sign in to comment.