Skip to content

Backport "Only lift inner expressions when lifting repeated Typed arguments" to LTS #19234

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 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ abstract class Lifter {
tree
}

/** Lift a function argument, stripping any NamedArg wrapper */
/** Lift a function argument, stripping any NamedArg wrapper and repeated Typed trees */
private def liftArg(defs: mutable.ListBuffer[Tree], arg: Tree, prefix: TermName = EmptyTermName)(using Context): Tree =
arg match {
case arg @ NamedArg(name, arg1) => cpy.NamedArg(arg)(name, lift(defs, arg1, prefix))
case arg @ Typed(arg1, tpt) if tpt.typeOpt.isRepeatedParam => cpy.Typed(arg)(lift(defs, arg1, prefix), tpt)
case arg => lift(defs, arg, prefix)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// scalac: -coverage-out:coverage
// scalajs: --skip

import concurrent.ExecutionContext.Implicits.global
import scala.concurrent.*
import scala.concurrent.duration.*
Expand Down
343 changes: 343 additions & 0 deletions tests/coverage/run/i16940/i16940.scoverage.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,343 @@
# 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
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
353
552
18
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
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
371
533
19
map
Apply
false
0
false
Future.sequence(Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true)))\n .map { result =>\n println(test)\n assert(test == 2)\n }

2
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
371
454
19
sequence
Apply
false
0
false
Future.sequence(Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true)))

3
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
387
453
19
apply
Apply
false
0
false
Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true))

4
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
387
390
19
Seq
Ident
false
0
false
Seq

5
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
391
421
19
brokenSynchronizedBlock
Apply
false
0
false
brokenSynchronizedBlock(false)

6
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
423
452
19
brokenSynchronizedBlock
Apply
false
0
false
brokenSynchronizedBlock(true)

7
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
$anonfun
486
499
21
println
Apply
false
0
false
println(test)

8
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
$anonfun
508
525
22
assertFailed
Apply
false
0
false
assert(test == 2)

9
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
$anonfun
508
525
22
assertFailed
Apply
true
0
false
assert(test == 2)

10
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
$anonfun
508
525
22
<none>
Literal
true
0
false
assert(test == 2)

11
i16940/i16940.scala
<empty>
Test$
Object
<empty>.Test$
<init>
539
548
24
seconds
Select
false
0
false
3.seconds

12
i16940/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
189
323
6
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
i16940/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
218
235
8
sleep
Apply
false
0
false
Thread.sleep(500)

14
i16940/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
212
239
7
<none>
Block
true
0
false
{\n Thread.sleep(500)\n }

15
i16940/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
239
239
9
<none>
Literal
true
0
false


16
i16940/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
242
321
10
synchronized
Apply
false
0
false
synchronized {\n val tmp = test\n Thread.sleep(1000)\n test = tmp + 1\n }

17
i16940/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
280
298
12
sleep
Apply
false
0
false
Thread.sleep(1000)

18
i16940/i16940.scala
<empty>
i16940$package$
Object
<empty>.i16940$package$
brokenSynchronizedBlock
128
155
6
brokenSynchronizedBlock
DefDef
false
0
false
def brokenSynchronizedBlock

13 changes: 13 additions & 0 deletions tests/coverage/run/i18233-min/i18233-min.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def aList =
List(Array[String]()*)

def arr =
Array("abc", "def")

def anotherList =
List(arr*)

object Test extends App {
println(aList)
println(anotherList)
}
Loading