Skip to content

Commit

Permalink
Backport "Don't lift the argument of a synchronized block in scover…
Browse files Browse the repository at this point in the history
…age" to LTS (#19169)

Backports #16941 to the LTS branch.

PR submitted by the release tooling.
  • Loading branch information
Kordyjan authored Dec 8, 2023
2 parents 1334656 + ff0f223 commit 6bd403e
Show file tree
Hide file tree
Showing 17 changed files with 380 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
* they shouldn't be lifted.
*/
val sym = fun.symbol
sym.exists && (isShortCircuitedOp(sym) || StringInterpolatorOpt.isCompilerIntrinsic(sym))
sym.exists && (isShortCircuitedOp(sym) || StringInterpolatorOpt.isCompilerIntrinsic(sym) || sym == defn.Object_synchronized)
end

val fun = tree.fun
Expand Down
326 changes: 326 additions & 0 deletions coverage/scoverage.coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
# 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
# ------------------------------------------
0
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
407
606
21
result
Apply
false
0
false
Await.result(\n Future.sequence(Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true)))\n .map { result =>\n println(test)\n assert(test == 2)\n },\n 3.seconds\n )

1
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
425
587
22
map
Apply
false
0
false
Future.sequence(Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true)))\n .map { result =>\n println(test)\n assert(test == 2)\n }

2
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
425
508
22
sequence
Apply
false
0
false
Future.sequence(Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true)))

3
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
441
507
22
apply
Apply
false
0
false
Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true))

4
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
441
444
22
Seq
Ident
false
0
false
Seq

5
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
445
475
22
brokenSynchronizedBlock
Apply
false
0
false
brokenSynchronizedBlock(false)

6
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
477
506
22
brokenSynchronizedBlock
Apply
false
0
false
brokenSynchronizedBlock(true)

7
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
$anonfun
540
553
24
println
Apply
false
0
false
println(test)

8
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
$anonfun
562
579
25
assertFailed
Apply
false
0
false
assert(test == 2)

9
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
$anonfun
562
579
25
assertFailed
Apply
true
0
false
assert(test == 2)

10
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
$anonfun
562
579
25
<none>
Literal
true
0
false
assert(test == 2)

11
tests/run/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
593
602
27
seconds
Select
false
0
false
3.seconds

12
tests/run/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
243
377
9
apply
Apply
false
0
false
Future {\n if (option) {\n Thread.sleep(500)\n }\n synchronized {\n val tmp = test\n Thread.sleep(1000)\n test = tmp + 1\n }\n}

13
tests/run/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
272
289
11
sleep
Apply
false
0
false
Thread.sleep(500)

14
tests/run/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
266
293
10
<none>
Block
true
0
false
{\n Thread.sleep(500)\n }

15
tests/run/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
296
375
13
synchronized
Apply
false
0
false
synchronized {\n val tmp = test\n Thread.sleep(1000)\n test = tmp + 1\n }

16
tests/run/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
334
352
15
sleep
Apply
false
0
false
Thread.sleep(1000)

17
tests/run/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
182
209
9
brokenSynchronizedBlock
DefDef
false
0
false
def brokenSynchronizedBlock

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
"""|//> using lib "io.cir@@
|package A
|""".stripMargin,
"io.circe"
"""|io.circe
|io.circul
|""".stripMargin
)

@Test def `multiple-deps` =
Expand Down Expand Up @@ -128,7 +130,9 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
"""|//> using dep "io.cir@@
|package A
|""".stripMargin,
"io.circe"
"""|io.circe
|io.circul
|""".stripMargin
)

@Test def `multiple-deps2` =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class HoverTypeSuite extends BaseHoverSuite:
"extension (s: String) def double2: String".hover
)

/* Currently there is no way to differentiate between
/* Currently there is no way to differentiate between
* trailing using params in extension parameter and the
* starting using params for the actual method.
* As user can actually supply params to them by hand when
Expand All @@ -134,15 +134,15 @@ class HoverTypeSuite extends BaseHoverSuite:
|class C
|object Foo:
| extension [T](using A)(s: T)(using B)
| def double[G](using C)(times: G) = (s.toString + s.toString) * times
| def double[G <: Int](using C)(times: G) = (s.toString + s.toString) * times
| end extension
| given A with {}
| given B with {}
| given C with {}
| "".<<doub@@le(1)>>
|end Foo
|""".stripMargin,
"extension [T](using A)(s: T) def double(using B)[G](using C)(times: G): String".hover
"extension [T](using A)(s: T) def double(using B)[G <: Int](using C)(times: G): String".hover
)

@Test def `extension-methods-complex-binary` =
Expand Down
8 changes: 4 additions & 4 deletions tests/neg-deep-subtype/i17435.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ object Test:
type JsonArray = mutable.Buffer[Json]

def encode(x: Json): Int = x match
case str: String => 1 // error
case b: Boolean => 2 // error
case i: Int => 3 // error
case d: Double => 4 // error
case str: String => 1
case b: Boolean => 2
case i: Int => 3
case d: Double => 4
case arr: JsonArray => 5 // error
case obj: JsonObject => 6 // error
case _ => 7
Loading

0 comments on commit 6bd403e

Please sign in to comment.