-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make incremental compilation aware of synthesized mirrors #18310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sealed trait Sealed | ||
class Child1 extends Sealed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Test { | ||
val s: Sealed = new Child1 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
scalaVersion := sys.props("plugin.scalaVersion") | ||
|
||
ThisBuild / incOptions ~= { _.withUseOptimizedSealed(true) } | ||
|
||
import sbt.internal.inc.Analysis | ||
import complete.DefaultParsers._ | ||
|
||
// Reset compiler iterations, necessary because tests run in batch mode | ||
val recordPreviousIterations = taskKey[Unit]("Record previous iterations.") | ||
recordPreviousIterations := { | ||
val log = streams.value.log | ||
CompileState.previousIterations = { | ||
val previousAnalysis = (previousCompile in Compile).value.analysis.asScala | ||
previousAnalysis match { | ||
case None => | ||
log.info("No previous analysis detected") | ||
0 | ||
case Some(a: Analysis) => a.compilations.allCompilations.size | ||
} | ||
} | ||
} | ||
|
||
val checkIterations = inputKey[Unit]("Verifies the accumulated number of iterations of incremental compilation.") | ||
|
||
checkIterations := { | ||
val expected: Int = (Space ~> NatBasic).parsed | ||
val actual: Int = ((compile in Compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations | ||
assert(expected == actual, s"Expected $expected compilations, got $actual") | ||
} |
3 changes: 3 additions & 0 deletions
3
sbt-test/source-dependencies/useOptimizedSealed/changes/Sealed1.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sealed trait Sealed | ||
class Child1 extends Sealed | ||
class Child2 extends Sealed |
4 changes: 4 additions & 0 deletions
4
sbt-test/source-dependencies/useOptimizedSealed/changes/Sealed2.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sealed trait Sealed | ||
class Child1 extends Sealed | ||
class Child2 extends Sealed | ||
class Child3 extends Sealed |
7 changes: 7 additions & 0 deletions
7
sbt-test/source-dependencies/useOptimizedSealed/changes/Test1.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Test { | ||
def foo(x: Sealed): Int = x match | ||
case _: Child1 => 1 | ||
case _: Child2 => 1 | ||
|
||
val s: Sealed = new Child1 | ||
} |
4 changes: 4 additions & 0 deletions
4
sbt-test/source-dependencies/useOptimizedSealed/project/CompileState.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This is necessary because tests are run in batch mode | ||
object CompileState { | ||
@volatile var previousIterations: Int = -1 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Compile Sealed.scala and Test.scala | ||
> compile | ||
> recordPreviousIterations | ||
|
||
# Add an extra children to Sealed | ||
$ copy-file changes/Sealed1.scala Sealed.scala | ||
|
||
# Only Sealed.scala needs to be recompiled because Test.scala does not | ||
# match on a value of type `Sealed`. | ||
> compile | ||
> checkIterations 1 | ||
|
||
> clean | ||
$ copy-file changes/Test1.scala Test.scala | ||
> compile | ||
> recordPreviousIterations | ||
|
||
# Add an extra children to Sealed again | ||
$ copy-file changes/Sealed2.scala Sealed.scala | ||
|
||
# Test.scala will be recompiled in a second round because it matches | ||
# on a value of type `Sealed`. | ||
> compile | ||
> checkIterations 2 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this going to reuse the closure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The by-name closure isn't guaranteed to be reused, it's up to the JVM