diff --git a/compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala b/compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala index 29572a4ae30d..3e5925899848 100644 --- a/compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala +++ b/compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala @@ -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 diff --git a/coverage/scoverage.coverage b/coverage/scoverage.coverage new file mode 100644 index 000000000000..d03837e604d4 --- /dev/null +++ b/coverage/scoverage.coverage @@ -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 + +Test$ +Object +.Test$ + +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 + +Test$ +Object +.Test$ + +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 + +Test$ +Object +.Test$ + +425 +508 +22 +sequence +Apply +false +0 +false +Future.sequence(Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true))) + +3 +tests/run/i16940.scala + +Test$ +Object +.Test$ + +441 +507 +22 +apply +Apply +false +0 +false +Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true)) + +4 +tests/run/i16940.scala + +Test$ +Object +.Test$ + +441 +444 +22 +Seq +Ident +false +0 +false +Seq + +5 +tests/run/i16940.scala + +Test$ +Object +.Test$ + +445 +475 +22 +brokenSynchronizedBlock +Apply +false +0 +false +brokenSynchronizedBlock(false) + +6 +tests/run/i16940.scala + +Test$ +Object +.Test$ + +477 +506 +22 +brokenSynchronizedBlock +Apply +false +0 +false +brokenSynchronizedBlock(true) + +7 +tests/run/i16940.scala + +Test$ +Object +.Test$ +$anonfun +540 +553 +24 +println +Apply +false +0 +false +println(test) + +8 +tests/run/i16940.scala + +Test$ +Object +.Test$ +$anonfun +562 +579 +25 +assertFailed +Apply +false +0 +false +assert(test == 2) + +9 +tests/run/i16940.scala + +Test$ +Object +.Test$ +$anonfun +562 +579 +25 +assertFailed +Apply +true +0 +false +assert(test == 2) + +10 +tests/run/i16940.scala + +Test$ +Object +.Test$ +$anonfun +562 +579 +25 + +Literal +true +0 +false +assert(test == 2) + +11 +tests/run/i16940.scala + +Test$ +Object +.Test$ + +593 +602 +27 +seconds +Select +false +0 +false +3.seconds + +12 +tests/run/i16940.scala + +i16940$package$ +Object +.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 + +i16940$package$ +Object +.i16940$package$ +brokenSynchronizedBlock +272 +289 +11 +sleep +Apply +false +0 +false +Thread.sleep(500) + +14 +tests/run/i16940.scala + +i16940$package$ +Object +.i16940$package$ +brokenSynchronizedBlock +266 +293 +10 + +Block +true +0 +false +{\n Thread.sleep(500)\n } + +15 +tests/run/i16940.scala + +i16940$package$ +Object +.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 + +i16940$package$ +Object +.i16940$package$ +brokenSynchronizedBlock +334 +352 +15 +sleep +Apply +false +0 +false +Thread.sleep(1000) + +17 +tests/run/i16940.scala + +i16940$package$ +Object +.i16940$package$ +brokenSynchronizedBlock +182 +209 +9 +brokenSynchronizedBlock +DefDef +false +0 +false +def brokenSynchronizedBlock + diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionScalaCliSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionScalaCliSuite.scala index 4018b2fabee4..1391635bea93 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionScalaCliSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionScalaCliSuite.scala @@ -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` = @@ -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` = diff --git a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTypeSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTypeSuite.scala index f370b9ab50d7..12c3a7be584f 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTypeSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTypeSuite.scala @@ -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 @@ -134,7 +134,7 @@ 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 {} @@ -142,7 +142,7 @@ class HoverTypeSuite extends BaseHoverSuite: | "".<> |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` = diff --git a/tests/neg-deep-subtype/i17435.scala b/tests/neg-deep-subtype/i17435.scala index aec165a18f56..46dd8f6fd0eb 100644 --- a/tests/neg-deep-subtype/i17435.scala +++ b/tests/neg-deep-subtype/i17435.scala @@ -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 diff --git a/tests/neg/i9740.check b/tests/neg/i9740.check deleted file mode 100644 index 359603a2863a..000000000000 --- a/tests/neg/i9740.check +++ /dev/null @@ -1,12 +0,0 @@ --- [E186] Type Error: tests/neg/i9740.scala:10:9 ----------------------------------------------------------------------- -10 | case RecoveryCompleted => println("Recovery completed") // error - | ^^^^^^^^^^^^^^^^^ - | Implausible pattern: - | RecoveryCompleted could match selector of type object TypedRecoveryCompleted - | only if there is an `equals` method identifying elements of the two types. --- [E186] Type Error: tests/neg/i9740.scala:15:9 ----------------------------------------------------------------------- -15 | case RecoveryCompleted => // error - | ^^^^^^^^^^^^^^^^^ - | Implausible pattern: - | RecoveryCompleted could match selector of type TypedRecoveryCompleted - | only if there is an `equals` method identifying elements of the two types. diff --git a/tests/neg/refinements-this.scala b/tests/neg/refinements-this.scala deleted file mode 100644 index f8d41bd85360..000000000000 --- a/tests/neg/refinements-this.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options -Xfatal-warnings - -class Outer: - type X = { type O = Outer.this.type } // ok - type Y = { type O = this.type } // error diff --git a/tests/neg/sip-53-exprimental-a.scala b/tests/neg/sip-53-exprimental-a.scala deleted file mode 100644 index 1b2f5a24d8a9..000000000000 --- a/tests/neg/sip-53-exprimental-a.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> using options -Yno-experimental - -import scala.quoted.* - -def foo(using Quotes): Unit = - (??? : Type[?]) match - case '[ (t, t, t) ] => // error // error - '{ ??? : Any } match - case '{ type u; $x: u } => // error - case '{ type u; ($ls: List[u]).map($f: u => Int) } => // error // error - diff --git a/tests/neg/sip-53-exprimental-b.scala b/tests/neg/sip-53-exprimental-b.scala deleted file mode 100644 index 0fb391c9cb5f..000000000000 --- a/tests/neg/sip-53-exprimental-b.scala +++ /dev/null @@ -1,10 +0,0 @@ -//> using options -Yno-experimental - -import scala.quoted.* - -def empty[K <: AnyKind : Type](using Quotes): Type[?] = - Type.of[K] match - case '[type t; `t`] => Type.of[t] // error - case '[type f[X]; `f`] => Type.of[f] // error - case '[type f[X <: Int, Y]; `f`] => Type.of[f] // error - case '[type k <: AnyKind; `k` ] => Type.of[k] // error diff --git a/tests/pos/cc-experimental.scala b/tests/pos/cc-experimental.scala deleted file mode 100644 index 4ee1f6732356..000000000000 --- a/tests/pos/cc-experimental.scala +++ /dev/null @@ -1,13 +0,0 @@ -//> using options -Yno-experimental - -package scala.runtime - -import language.experimental.captureChecking - -object test: - type T = Pure - -class Foo extends Object, Pure: - val x: Pure = ??? - def foo() = () - diff --git a/tests/pos/dotty-experimental.scala b/tests/pos/dotty-experimental.scala index ada386143a0a..94bc6cc9eb84 100644 --- a/tests/pos/dotty-experimental.scala +++ b/tests/pos/dotty-experimental.scala @@ -1,6 +1,6 @@ //> using options -Yno-experimental -import language.experimental.captureChecking +package dotty.tools object test { val x = caps.cap diff --git a/tests/run-staging/quote-nested-6.check b/tests/run-staging/quote-nested-6.check index 81e20d6782a3..2ae8b0d26e47 100644 --- a/tests/run-staging/quote-nested-6.check +++ b/tests/run-staging/quote-nested-6.check @@ -1,7 +1,7 @@ { - type T[X] = [A >: scala.Nothing <: scala.Any] =>> scala.collection.immutable.List[A][X] + type T[X] = [A >: scala.Nothing <: scala.Any] => scala.collection.immutable.List[A][X] val x: java.lang.String = "foo" - val z: [X >: scala.Nothing <: scala.Any] =>> scala.collection.immutable.List[X][java.lang.String] = scala.List.apply[java.lang.String](x) + val z: [X >: scala.Nothing <: scala.Any] => scala.collection.immutable.List[X][java.lang.String] = scala.List.apply[java.lang.String](x) (x: java.lang.String) } diff --git a/tests/run-tasty-inspector/tastyPaths.check b/tests/run-tasty-inspector/tastyPaths.check index f9d3486040b8..4aab4bcb2590 100644 --- a/tests/run-tasty-inspector/tastyPaths.check +++ b/tests/run-tasty-inspector/tastyPaths.check @@ -1,2 +1,2 @@ -List(/tastyPaths/I8163.tasty) +List(/tastyPaths/I8163.class) `reflect.SourceFile.current` cannot be called within the TASTy ispector diff --git a/tests/run/erased-15.scala b/tests/run/erased-15.scala index ac3adc428ffb..68c0e6d5105a 100644 --- a/tests/run/erased-15.scala +++ b/tests/run/erased-15.scala @@ -12,7 +12,7 @@ object Test { } } -class Foo extends PolyFunction { +class Foo extends ErasedFunction { def apply(erased x: Int): Int = { println("Foo.apply") 42 diff --git a/tests/run/i16940.scala b/tests/run/i16940.scala new file mode 100644 index 000000000000..5c16b6d3333d --- /dev/null +++ b/tests/run/i16940.scala @@ -0,0 +1,30 @@ +// scalac: -coverage-out:coverage +// scalajs: --skip + +import concurrent.ExecutionContext.Implicits.global +import scala.concurrent.* +import scala.concurrent.duration.* + +var test = 0 + +def brokenSynchronizedBlock(option: Boolean): Future[Unit] = Future { + if (option) { + Thread.sleep(500) + } + synchronized { + val tmp = test + Thread.sleep(1000) + test = tmp + 1 + } +} + +object Test extends App { + Await.result( + Future.sequence(Seq(brokenSynchronizedBlock(false), brokenSynchronizedBlock(true))) + .map { result => + println(test) + assert(test == 2) + }, + 3.seconds + ) +} diff --git a/tests/run/quotes-reflection.check b/tests/run/quotes-reflection.check index ed01fb47ac5f..584714624b45 100644 --- a/tests/run/quotes-reflection.check +++ b/tests/run/quotes-reflection.check @@ -4,7 +4,7 @@ method m2: (i: scala.Int) isGiven=false isImplicit=false erasedArgs=List(true) method m3: (i: scala.Int, j: scala.Int) isGiven=false isImplicit=false erasedArgs=List(false, true) method m4: (i: EC) isGiven=false isImplicit=false erasedArgs=List(true) val l1: scala.ContextFunction1[scala.Int, scala.Int] -val l2: scala.PolyFunction with apply: (x: scala.Int @scala.annotation.internal.ErasedParam) isImplicit=false erasedParams=List(true) -val l3: scala.PolyFunction with apply: (x: scala.Int @scala.annotation.internal.ErasedParam) isImplicit=true erasedParams=List(true) -val l4: scala.PolyFunction with apply: (x: scala.Int, y: scala.Int @scala.annotation.internal.ErasedParam) isImplicit=false erasedParams=List(false, true) -val l5: scala.PolyFunction with apply: (x: EC @scala.annotation.internal.ErasedParam) isImplicit=false erasedParams=List(true) +val l2: scala.runtime.ErasedFunction with apply: (x: scala.Int @scala.annotation.internal.ErasedParam) isImplicit=false erasedParams=List(true) +val l3: scala.runtime.ErasedFunction with apply: (x: scala.Int @scala.annotation.internal.ErasedParam) isImplicit=true erasedParams=List(true) +val l4: scala.runtime.ErasedFunction with apply: (x: scala.Int, y: scala.Int @scala.annotation.internal.ErasedParam) isImplicit=false erasedParams=List(false, true) +val l5: scala.runtime.ErasedFunction with apply: (x: EC @scala.annotation.internal.ErasedParam) isImplicit=false erasedParams=List(true) diff --git a/tests/run/quotes-reflection/Macros_1.scala b/tests/run/quotes-reflection/Macros_1.scala index 5945d39a097a..f7b1187433f0 100644 --- a/tests/run/quotes-reflection/Macros_1.scala +++ b/tests/run/quotes-reflection/Macros_1.scala @@ -20,7 +20,7 @@ def inspect2[A: Type](using Quotes): Expr[String] = { s"method $name: $paramStr" case vd @ ValDef(name, tpt, body) => tpt.tpe match - case Refinement(parent, "apply", tpe: MethodType) if parent == defn.PolyFunctionClass.typeRef => + case Refinement(parent, "apply", tpe: MethodType) if parent == defn.ErasedFunctionClass.typeRef => assert(tpt.tpe.isErasedFunctionType) val params = tpe.paramNames.zip(tpe.paramTypes).map((n, t) => s"$n: ${t.show}").mkString("(", ", ", ")")