-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix coverage serialization when encountering macro suspension #22303
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 all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
817d72f
Fix macro suspensions breaking coverage
jchyb 66ad0cd
Support compiling multiple files in coverage tests
jchyb d07040d
Fix coverage for macro suspension after InstrumentCoverage
jchyb f7b2aa5
Initialise Coverage object only when the option is used
jchyb 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
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,13 @@ | ||
package example | ||
|
||
sealed trait Test | ||
|
||
object Test { | ||
case object Foo extends Test | ||
|
||
val visitorType = mkVisitorType[Test] | ||
|
||
trait Visitor[A] { | ||
type V[a] = visitorType.Out[a] | ||
} | ||
} |
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 @@ | ||
package example | ||
|
||
val _ = Test.Foo |
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,12 @@ | ||
package example | ||
|
||
import scala.quoted.* | ||
|
||
private def mkVisitorTypeImpl[T: Type](using q: Quotes): Expr[VisitorType[T]] = | ||
'{new VisitorType[T]{}} | ||
|
||
transparent inline def mkVisitorType[T]: VisitorType[T] = ${ mkVisitorTypeImpl[T] } | ||
|
||
trait VisitorType[T] { | ||
type Out[A] | ||
} |
88 changes: 88 additions & 0 deletions
88
tests/coverage/pos/macro-late-suspend/test.scoverage.check
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,88 @@ | ||
# Coverage data, format version: 3.0 | ||
# Statement data: | ||
# - id | ||
# - source path | ||
# - package name | ||
# - class name | ||
# - class type (Class, Object or Trait) | ||
# - full class name | ||
# - method name | ||
# - start offset | ||
# - end offset | ||
# - line number | ||
# - symbol name | ||
# - tree name | ||
# - is branch | ||
# - invocations count | ||
# - is ignored | ||
# - description (can be multi-line) | ||
# '' sign | ||
# ------------------------------------------ | ||
1 | ||
macro-late-suspend/VisitorMacros.scala | ||
example | ||
VisitorMacros$package | ||
Object | ||
example.VisitorMacros$package | ||
mkVisitorTypeImpl | ||
124 | ||
144 | ||
6 | ||
unpickleExprV2 | ||
Apply | ||
false | ||
0 | ||
false | ||
new VisitorType[T]{} | ||
|
||
2 | ||
macro-late-suspend/VisitorMacros.scala | ||
example | ||
VisitorMacros$package | ||
Object | ||
example.VisitorMacros$package | ||
mkVisitorTypeImpl | ||
40 | ||
69 | ||
5 | ||
mkVisitorTypeImpl | ||
DefDef | ||
false | ||
0 | ||
false | ||
private def mkVisitorTypeImpl | ||
|
||
3 | ||
macro-late-suspend/Test.scala | ||
example | ||
Test | ||
Object | ||
example.Test | ||
<init> | ||
102 | ||
121 | ||
8 | ||
<init> | ||
Apply | ||
false | ||
0 | ||
false | ||
mkVisitorType[Test] | ||
|
||
4 | ||
macro-late-suspend/UsesTest.scala | ||
example | ||
UsesTest$package | ||
Object | ||
example.UsesTest$package | ||
<init> | ||
22 | ||
22 | ||
3 | ||
<none> | ||
Literal | ||
true | ||
0 | ||
false | ||
|
||
|
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 |
File renamed without changes.
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 @@ | ||
List() | ||
List(abc, def) |
File renamed without changes.
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 @@ | ||
Baz |
File renamed without changes.
File renamed without changes.
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 @@ | ||
>>> hello <<< |
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,8 @@ | ||
import scala.quoted.{Expr, Quotes} | ||
|
||
object Macro: | ||
inline def decorate(inline s: String): String = ${ decorateQuotes('s) } | ||
def decorateQuotes(s: Expr[String])(using Quotes): Expr[String] = '{ ">>> " + $s + " <<<" } | ||
|
||
object Greeting: | ||
def greet() = "hello" |
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 @@ | ||
object Test: | ||
def main(args: Array[String]): Unit = | ||
println(Macro.decorate(Greeting.greet())) | ||
|
Oops, something went wrong.
Oops, something went wrong.
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 name also wrong btw? i182233-min.check has an added 2
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.
Yes. Weird that the added assertion does not throw... I'll try to look at this closer tomorrow
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.
Ah I see the issue - for that one, the first file returned by the iterator is actually
i182233-min.check
so after replacing .scala with .check, we end up with the same file, so it passes the assertion (and is indeed used in the run test).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.
Ach, so not a big deal then