Skip to content

Commit 6bd403e

Browse files
authored
Backport "Don't lift the argument of a synchronized block in scoverage" to LTS (#19169)
Backports #16941 to the LTS branch. PR submitted by the release tooling.
2 parents 1334656 + ff0f223 commit 6bd403e

File tree

17 files changed

+380
-71
lines changed

17 files changed

+380
-71
lines changed

Diff for: compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
457457
* they shouldn't be lifted.
458458
*/
459459
val sym = fun.symbol
460-
sym.exists && (isShortCircuitedOp(sym) || StringInterpolatorOpt.isCompilerIntrinsic(sym))
460+
sym.exists && (isShortCircuitedOp(sym) || StringInterpolatorOpt.isCompilerIntrinsic(sym) || sym == defn.Object_synchronized)
461461
end
462462

463463
val fun = tree.fun

Diff for: coverage/scoverage.coverage

+326
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,326 @@
1+
# Coverage data, format version: 3.0
2+
# Statement data:
3+
# - id
4+
# - source path
5+
# - package name
6+
# - class name
7+
# - class type (Class, Object or Trait)
8+
# - full class name
9+
# - method name
10+
# - start offset
11+
# - end offset
12+
# - line number
13+
# - symbol name
14+
# - tree name
15+
# - is branch
16+
# - invocations count
17+
# - is ignored
18+
# - description (can be multi-line)
19+
# ' ' sign
20+
# ------------------------------------------
21+
0
22+
tests/run/i16940.scala
23+
<empty>
24+
Test$
25+
Object
26+
<empty>.Test$
27+
<init>
28+
407
29+
606
30+
21
31+
result
32+
Apply
33+
false
34+
0
35+
false
36+
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 )
37+
38+
1
39+
tests/run/i16940.scala
40+
<empty>
41+
Test$
42+
Object
43+
<empty>.Test$
44+
<init>
45+
425
46+
587
47+
22
48+
map
49+
Apply
50+
false
51+
0
52+
false
53+
Future.sequence(Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true)))\n .map { result =>\n println(test)\n assert(test == 2)\n }
54+
55+
2
56+
tests/run/i16940.scala
57+
<empty>
58+
Test$
59+
Object
60+
<empty>.Test$
61+
<init>
62+
425
63+
508
64+
22
65+
sequence
66+
Apply
67+
false
68+
0
69+
false
70+
Future.sequence(Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true)))
71+
72+
3
73+
tests/run/i16940.scala
74+
<empty>
75+
Test$
76+
Object
77+
<empty>.Test$
78+
<init>
79+
441
80+
507
81+
22
82+
apply
83+
Apply
84+
false
85+
0
86+
false
87+
Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true))
88+
89+
4
90+
tests/run/i16940.scala
91+
<empty>
92+
Test$
93+
Object
94+
<empty>.Test$
95+
<init>
96+
441
97+
444
98+
22
99+
Seq
100+
Ident
101+
false
102+
0
103+
false
104+
Seq
105+
106+
5
107+
tests/run/i16940.scala
108+
<empty>
109+
Test$
110+
Object
111+
<empty>.Test$
112+
<init>
113+
445
114+
475
115+
22
116+
brokenSynchronizedBlock
117+
Apply
118+
false
119+
0
120+
false
121+
brokenSynchronizedBlock(false)
122+
123+
6
124+
tests/run/i16940.scala
125+
<empty>
126+
Test$
127+
Object
128+
<empty>.Test$
129+
<init>
130+
477
131+
506
132+
22
133+
brokenSynchronizedBlock
134+
Apply
135+
false
136+
0
137+
false
138+
brokenSynchronizedBlock(true)
139+
140+
7
141+
tests/run/i16940.scala
142+
<empty>
143+
Test$
144+
Object
145+
<empty>.Test$
146+
$anonfun
147+
540
148+
553
149+
24
150+
println
151+
Apply
152+
false
153+
0
154+
false
155+
println(test)
156+
157+
8
158+
tests/run/i16940.scala
159+
<empty>
160+
Test$
161+
Object
162+
<empty>.Test$
163+
$anonfun
164+
562
165+
579
166+
25
167+
assertFailed
168+
Apply
169+
false
170+
0
171+
false
172+
assert(test == 2)
173+
174+
9
175+
tests/run/i16940.scala
176+
<empty>
177+
Test$
178+
Object
179+
<empty>.Test$
180+
$anonfun
181+
562
182+
579
183+
25
184+
assertFailed
185+
Apply
186+
true
187+
0
188+
false
189+
assert(test == 2)
190+
191+
10
192+
tests/run/i16940.scala
193+
<empty>
194+
Test$
195+
Object
196+
<empty>.Test$
197+
$anonfun
198+
562
199+
579
200+
25
201+
<none>
202+
Literal
203+
true
204+
0
205+
false
206+
assert(test == 2)
207+
208+
11
209+
tests/run/i16940.scala
210+
<empty>
211+
Test$
212+
Object
213+
<empty>.Test$
214+
<init>
215+
593
216+
602
217+
27
218+
seconds
219+
Select
220+
false
221+
0
222+
false
223+
3.seconds
224+
225+
12
226+
tests/run/i16940.scala
227+
<empty>
228+
i16940$package$
229+
Object
230+
<empty>.i16940$package$
231+
brokenSynchronizedBlock
232+
243
233+
377
234+
9
235+
apply
236+
Apply
237+
false
238+
0
239+
false
240+
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}
241+
242+
13
243+
tests/run/i16940.scala
244+
<empty>
245+
i16940$package$
246+
Object
247+
<empty>.i16940$package$
248+
brokenSynchronizedBlock
249+
272
250+
289
251+
11
252+
sleep
253+
Apply
254+
false
255+
0
256+
false
257+
Thread.sleep(500)
258+
259+
14
260+
tests/run/i16940.scala
261+
<empty>
262+
i16940$package$
263+
Object
264+
<empty>.i16940$package$
265+
brokenSynchronizedBlock
266+
266
267+
293
268+
10
269+
<none>
270+
Block
271+
true
272+
0
273+
false
274+
{\n Thread.sleep(500)\n }
275+
276+
15
277+
tests/run/i16940.scala
278+
<empty>
279+
i16940$package$
280+
Object
281+
<empty>.i16940$package$
282+
brokenSynchronizedBlock
283+
296
284+
375
285+
13
286+
synchronized
287+
Apply
288+
false
289+
0
290+
false
291+
synchronized {\n val tmp = test\n Thread.sleep(1000)\n test = tmp + 1\n }
292+
293+
16
294+
tests/run/i16940.scala
295+
<empty>
296+
i16940$package$
297+
Object
298+
<empty>.i16940$package$
299+
brokenSynchronizedBlock
300+
334
301+
352
302+
15
303+
sleep
304+
Apply
305+
false
306+
0
307+
false
308+
Thread.sleep(1000)
309+
310+
17
311+
tests/run/i16940.scala
312+
<empty>
313+
i16940$package$
314+
Object
315+
<empty>.i16940$package$
316+
brokenSynchronizedBlock
317+
182
318+
209
319+
9
320+
brokenSynchronizedBlock
321+
DefDef
322+
false
323+
0
324+
false
325+
def brokenSynchronizedBlock
326+

Diff for: presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionScalaCliSuite.scala

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
1111
"""|//> using lib "io.cir@@
1212
|package A
1313
|""".stripMargin,
14-
"io.circe"
14+
"""|io.circe
15+
|io.circul
16+
|""".stripMargin
1517
)
1618

1719
@Test def `multiple-deps` =
@@ -128,7 +130,9 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
128130
"""|//> using dep "io.cir@@
129131
|package A
130132
|""".stripMargin,
131-
"io.circe"
133+
"""|io.circe
134+
|io.circul
135+
|""".stripMargin
132136
)
133137

134138
@Test def `multiple-deps2` =

Diff for: presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTypeSuite.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class HoverTypeSuite extends BaseHoverSuite:
119119
"extension (s: String) def double2: String".hover
120120
)
121121

122-
/* Currently there is no way to differentiate between
122+
/* Currently there is no way to differentiate between
123123
* trailing using params in extension parameter and the
124124
* starting using params for the actual method.
125125
* As user can actually supply params to them by hand when
@@ -134,15 +134,15 @@ class HoverTypeSuite extends BaseHoverSuite:
134134
|class C
135135
|object Foo:
136136
| extension [T](using A)(s: T)(using B)
137-
| def double[G](using C)(times: G) = (s.toString + s.toString) * times
137+
| def double[G <: Int](using C)(times: G) = (s.toString + s.toString) * times
138138
| end extension
139139
| given A with {}
140140
| given B with {}
141141
| given C with {}
142142
| "".<<doub@@le(1)>>
143143
|end Foo
144144
|""".stripMargin,
145-
"extension [T](using A)(s: T) def double(using B)[G](using C)(times: G): String".hover
145+
"extension [T](using A)(s: T) def double(using B)[G <: Int](using C)(times: G): String".hover
146146
)
147147

148148
@Test def `extension-methods-complex-binary` =

Diff for: tests/neg-deep-subtype/i17435.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ object Test:
1616
type JsonArray = mutable.Buffer[Json]
1717

1818
def encode(x: Json): Int = x match
19-
case str: String => 1 // error
20-
case b: Boolean => 2 // error
21-
case i: Int => 3 // error
22-
case d: Double => 4 // error
19+
case str: String => 1
20+
case b: Boolean => 2
21+
case i: Int => 3
22+
case d: Double => 4
2323
case arr: JsonArray => 5 // error
2424
case obj: JsonObject => 6 // error
2525
case _ => 7

0 commit comments

Comments
 (0)