From abf795c6cf23b4464c2f7715b0b4c39a2b24a602 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Sat, 29 Jun 2024 15:01:06 +0200 Subject: [PATCH 1/3] Switch default source version to 3.6 --- compiler/src/dotty/tools/dotc/config/SourceVersion.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/config/SourceVersion.scala b/compiler/src/dotty/tools/dotc/config/SourceVersion.scala index 935b95003729..38df682de771 100644 --- a/compiler/src/dotty/tools/dotc/config/SourceVersion.scala +++ b/compiler/src/dotty/tools/dotc/config/SourceVersion.scala @@ -28,7 +28,7 @@ enum SourceVersion: def isAtMost(v: SourceVersion) = stable.ordinal <= v.ordinal object SourceVersion extends Property.Key[SourceVersion]: - def defaultSourceVersion = `3.5` + def defaultSourceVersion = `3.6` /** language versions that may appear in a language import, are deprecated, but not removed from the standard library. */ val illegalSourceVersionNames = List("3.1-migration").map(_.toTermName) From aad6f7d1c091c6a59f44ae5b56bffd180f22b64a Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Wed, 3 Jul 2024 14:26:25 +0200 Subject: [PATCH 2/3] Adapt the test suite to scala 3.6 --- tests/neg/given-loop-prevention.check | 14 ++------ tests/neg/i20415.scala | 2 -- tests/neg/i6716.check | 14 -------- tests/neg/i6716.scala | 17 ++++------ tests/neg/i7294.check | 30 ++++------------- tests/neg/i7294.scala | 2 +- tests/neg/looping-givens.check | 48 --------------------------- tests/neg/looping-givens.scala | 11 ------ tests/pos/i20415.scala | 2 ++ tests/pos/i6716.scala | 18 +++++----- tests/pos/looping-givens.scala | 7 ++-- tests/run/i6716.scala | 2 +- 12 files changed, 32 insertions(+), 135 deletions(-) delete mode 100644 tests/neg/i20415.scala delete mode 100644 tests/neg/i6716.check delete mode 100644 tests/neg/looping-givens.check delete mode 100644 tests/neg/looping-givens.scala create mode 100644 tests/pos/i20415.scala diff --git a/tests/neg/given-loop-prevention.check b/tests/neg/given-loop-prevention.check index 460adf03be49..cbaeec2474f4 100644 --- a/tests/neg/given-loop-prevention.check +++ b/tests/neg/given-loop-prevention.check @@ -1,14 +1,4 @@ --- Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------------------ +-- [E172] Type Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------ 10 | given List[Foo] = List(summon[Foo]) // error | ^ - | Result of implicit search for Foo will change. - | Current result Baz.given_Foo will be no longer eligible - | because it is not defined before the search position. - | Result with new rules: No Matching Implicit. - | To opt into the new rules, compile with `-source future` or use - | the `scala.language.future` language import. - | - | To fix the problem without the language import, you could try one of the following: - | - use a `given ... with` clause as the enclosing given, - | - rearrange definitions so that Baz.given_Foo comes earlier, - | - use an explicit argument. + | No given instance of type Foo was found for parameter x of method summon in object Predef diff --git a/tests/neg/i20415.scala b/tests/neg/i20415.scala deleted file mode 100644 index 14582e40aa9d..000000000000 --- a/tests/neg/i20415.scala +++ /dev/null @@ -1,2 +0,0 @@ -class Foo: - given ord: Ordering[Int] = summon[Ordering[Int]] // error diff --git a/tests/neg/i6716.check b/tests/neg/i6716.check deleted file mode 100644 index 0144f539f53c..000000000000 --- a/tests/neg/i6716.check +++ /dev/null @@ -1,14 +0,0 @@ --- Error: tests/neg/i6716.scala:11:39 ---------------------------------------------------------------------------------- -11 | given Monad[Bar] = summon[Monad[Foo]] // error - | ^ - | Result of implicit search for Monad[Foo] will change. - | Current result Bar.given_Monad_Bar will be no longer eligible - | because it is not defined before the search position. - | Result with new rules: Foo.given_Monad_Foo. - | To opt into the new rules, compile with `-source future` or use - | the `scala.language.future` language import. - | - | To fix the problem without the language import, you could try one of the following: - | - use a `given ... with` clause as the enclosing given, - | - rearrange definitions so that Bar.given_Monad_Bar comes earlier, - | - use an explicit argument. diff --git a/tests/neg/i6716.scala b/tests/neg/i6716.scala index 8b37d4e223ac..eece8af9e560 100644 --- a/tests/neg/i6716.scala +++ b/tests/neg/i6716.scala @@ -1,17 +1,12 @@ - -trait Monad[T]: - def id: String class Foo -object Foo { - given Monad[Foo] with { def id = "Foo" } -} -opaque type Bar = Foo object Bar { - given Monad[Bar] = summon[Monad[Foo]] // error + given Foo with {} + given List[Foo] = List(summon[Foo]) // ok } -object Test extends App { - println(summon[Monad[Foo]].id) - println(summon[Monad[Bar]].id) +object Baz { + @annotation.nowarn + given List[Foo] = List(summon[Foo]) // error + given Foo with {} } diff --git a/tests/neg/i7294.check b/tests/neg/i7294.check index d6e559997f78..30c076470899 100644 --- a/tests/neg/i7294.check +++ b/tests/neg/i7294.check @@ -1,25 +1,9 @@ --- Error: tests/neg/i7294.scala:7:10 ----------------------------------------------------------------------------------- -7 | case x: T => x.g(10) // error // error - | ^ - | Result of implicit search for scala.reflect.TypeTest[Nothing, T] will change. - | Current result foo.f will be no longer eligible - | because it is not defined before the search position. - | Result with new rules: No Matching Implicit. - | To opt into the new rules, compile with `-source future` or use - | the `scala.language.future` language import. - | - | To fix the problem without the language import, you could try one of the following: - | - use a `given ... with` clause as the enclosing given, - | - rearrange definitions so that foo.f comes earlier, - | - use an explicit argument. - | - | where: T is a type in given instance f with bounds <: foo.Foo --- [E007] Type Mismatch Error: tests/neg/i7294.scala:7:18 -------------------------------------------------------------- -7 | case x: T => x.g(10) // error // error - | ^^^^^^^ - | Found: Any - | Required: T - | - | where: T is a type in given instance f with bounds <: foo.Foo +-- [E007] Type Mismatch Error: tests/neg/i7294.scala:7:15 -------------------------------------------------------------- +7 | case x: T => x.g(10) // error + | ^ + | Found: (x : Nothing) + | Required: ?{ g: ? } + | Note that implicit conversions were not tried because the result of an implicit conversion + | must be more specific than ?{ g: [applied to (10) returning T] } | | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i7294.scala b/tests/neg/i7294.scala index fbb00f9b7e89..2725109e79e8 100644 --- a/tests/neg/i7294.scala +++ b/tests/neg/i7294.scala @@ -4,7 +4,7 @@ package foo trait Foo { def g(x: Any): Any } inline given f[T <: Foo]: T = ??? match { - case x: T => x.g(10) // error // error + case x: T => x.g(10) // error } @main def Test = f diff --git a/tests/neg/looping-givens.check b/tests/neg/looping-givens.check deleted file mode 100644 index 1e7ee08d79df..000000000000 --- a/tests/neg/looping-givens.check +++ /dev/null @@ -1,48 +0,0 @@ --- Error: tests/neg/looping-givens.scala:9:22 -------------------------------------------------------------------------- -9 | given aa: A = summon // error - | ^ - | Result of implicit search for T will change. - | Current result ab will be no longer eligible - | because it is not defined before the search position. - | Result with new rules: a. - | To opt into the new rules, compile with `-source future` or use - | the `scala.language.future` language import. - | - | To fix the problem without the language import, you could try one of the following: - | - use a `given ... with` clause as the enclosing given, - | - rearrange definitions so that ab comes earlier, - | - use an explicit argument. - | - | where: T is a type variable with constraint <: A --- Error: tests/neg/looping-givens.scala:10:22 ------------------------------------------------------------------------- -10 | given bb: B = summon // error - | ^ - | Result of implicit search for T will change. - | Current result ab will be no longer eligible - | because it is not defined before the search position. - | Result with new rules: b. - | To opt into the new rules, compile with `-source future` or use - | the `scala.language.future` language import. - | - | To fix the problem without the language import, you could try one of the following: - | - use a `given ... with` clause as the enclosing given, - | - rearrange definitions so that ab comes earlier, - | - use an explicit argument. - | - | where: T is a type variable with constraint <: B --- Error: tests/neg/looping-givens.scala:11:28 ------------------------------------------------------------------------- -11 | given ab: (A & B) = summon // error - | ^ - | Result of implicit search for T will change. - | Current result ab will be no longer eligible - | because it is not defined before the search position. - | Result with new rules: Search Failure: joint(ab, ab). - | To opt into the new rules, compile with `-source future` or use - | the `scala.language.future` language import. - | - | To fix the problem without the language import, you could try one of the following: - | - use a `given ... with` clause as the enclosing given, - | - rearrange definitions so that ab comes earlier, - | - use an explicit argument. - | - | where: T is a type variable with constraint <: A & B diff --git a/tests/neg/looping-givens.scala b/tests/neg/looping-givens.scala deleted file mode 100644 index 57dc95f99aab..000000000000 --- a/tests/neg/looping-givens.scala +++ /dev/null @@ -1,11 +0,0 @@ -//> options -source 3.4 - -class A -class B - -given joint(using a: A, b: B): (A & B) = ??? - -def foo(using a: A, b: B) = - given aa: A = summon // error - given bb: B = summon // error - given ab: (A & B) = summon // error diff --git a/tests/pos/i20415.scala b/tests/pos/i20415.scala new file mode 100644 index 000000000000..500dcb83ba15 --- /dev/null +++ b/tests/pos/i20415.scala @@ -0,0 +1,2 @@ +class Foo: + given ord: Ordering[Int] = summon[Ordering[Int]] diff --git a/tests/pos/i6716.scala b/tests/pos/i6716.scala index f02559af1e82..617adc3c09f0 100644 --- a/tests/pos/i6716.scala +++ b/tests/pos/i6716.scala @@ -1,14 +1,16 @@ -//> using options -Xfatal-warnings -source 3.4 - +trait Monad[T]: + def id: String class Foo +object Foo { + given Monad[Foo] with { def id = "Foo" } +} +opaque type Bar = Foo object Bar { - given Foo with {} - given List[Foo] = List(summon[Foo]) // ok + given Monad[Bar] = summon[Monad[Foo]] } -object Baz { - @annotation.nowarn - given List[Foo] = List(summon[Foo]) // gives a warning, which is suppressed - given Foo with {} +object Test extends App { + println(summon[Monad[Foo]].id) + println(summon[Monad[Bar]].id) } diff --git a/tests/pos/looping-givens.scala b/tests/pos/looping-givens.scala index 0e615c8251df..d7d086358099 100644 --- a/tests/pos/looping-givens.scala +++ b/tests/pos/looping-givens.scala @@ -1,4 +1,3 @@ -import language.future class A class B @@ -6,6 +5,6 @@ class B given joint(using a: A, b: B): (A & B) = ??? def foo(using a: A, b: B) = - given aa: A = summon // error - given bb: B = summon // error - given ab: (A & B) = summon // error + given aa: A = summon // resolves to a + given bb: B = summon // resolves to b + given ab: (A & B) = summon // resolves to joint(aa, bb) diff --git a/tests/run/i6716.scala b/tests/run/i6716.scala index 3bef45ac7465..e793381cce1c 100644 --- a/tests/run/i6716.scala +++ b/tests/run/i6716.scala @@ -1,4 +1,4 @@ -//> using options -Xfatal-warnings -source future +//> using options -Xfatal-warnings trait Monad[T]: def id: String From 36146eb6f7c5090a2be81df1164a07af1d5a5fd3 Mon Sep 17 00:00:00 2001 From: Hamza REMMAL Date: Fri, 28 Jun 2024 18:00:23 +0200 Subject: [PATCH 3/3] Stabilise SIP-47 --- .../src/dotty/tools/dotc/config/Feature.scala | 3 +- .../dotty/tools/dotc/parsing/Parsers.scala | 7 +---- .../generalized-method-syntax.md | 10 ++----- .../runtime/stdLibPatches/language.scala | 1 + .../SignatureHelpInterleavingSuite.scala | 3 -- .../src/tests/extensionParams.scala | 2 -- .../src/tests/methodsAndConstructors.scala | 2 -- tests/neg/interleaving-ab.scala | 3 +- tests/neg/interleaving-params.scala | 1 - .../neg/interleaving-signatureCollision.scala | 1 - tests/neg/interleaving-typeApply.check | 28 +++++++++---------- tests/neg/interleaving-typeApply.scala | 3 +- tests/neg/interleaving-unmatched.scala | 1 - tests/neg/interleavingExperimental.check | 4 +++ tests/neg/interleavingExperimental.scala | 3 ++ tests/neg/namedTypeParams.check | 8 +++--- tests/neg/namedTypeParams.scala | 1 - tests/neg/overrides.scala | 6 ---- tests/pos/interleaving-ba.scala | 1 - tests/pos/interleaving-chainedParams.scala | 1 - tests/pos/interleaving-classless.scala | 1 - tests/pos/interleaving-functor.scala | 1 - tests/pos/interleaving-newline.scala | 1 - tests/pos/interleaving-overload.scala | 1 - tests/pos/interleaving-params.scala | 1 - .../pos/interleaving-signatureCollision.scala | 1 - tests/pos/interleaving-typeApply.scala | 2 -- tests/pos/interleavingExperimental.scala | 5 ++++ tests/pos/namedTypeParams.scala | 1 - tests/pos/overrides.scala | 5 ---- tests/run/interleaving.scala | 1 - 31 files changed, 38 insertions(+), 71 deletions(-) rename docs/_docs/reference/{experimental => other-new-features}/generalized-method-syntax.md (92%) create mode 100644 tests/neg/interleavingExperimental.check create mode 100644 tests/neg/interleavingExperimental.scala create mode 100644 tests/pos/interleavingExperimental.scala diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index c04c58b419c9..fed67b380092 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -121,7 +121,8 @@ object Feature: def namedTypeArgsEnabled(using Context) = enabled(namedTypeArguments) - def clauseInterleavingEnabled(using Context) = enabled(clauseInterleaving) + def clauseInterleavingEnabled(using Context) = + sourceVersion.isAtLeast(`3.6`) || enabled(clauseInterleaving) def genericNumberLiteralsEnabled(using Context) = enabled(genericNumberLiterals) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 4c13934f3473..07fb97191f2d 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3836,9 +3836,6 @@ object Parsers { /** DefDef ::= DefSig [‘:’ Type] [‘=’ Expr] * | this TypelessClauses [DefImplicitClause] `=' ConstrExpr - * DefSig ::= id [DefTypeParamClause] DefTermParamClauses - * - * if clauseInterleaving is enabled: * DefSig ::= id [DefParamClauses] [DefImplicitClause] */ def defDefOrDcl(start: Offset, mods: Modifiers, numLeadParams: Int = 0): DefDef = atSpan(start, nameStart) { @@ -3878,13 +3875,11 @@ object Parsers { val ident = termIdent() var name = ident.name.asTermName val paramss = - if in.featureEnabled(Feature.clauseInterleaving) then - // If you are making interleaving stable manually, please refer to the PR introducing it instead, section "How to make non-experimental" + if Feature.clauseInterleavingEnabled(using in.languageImportContext) then typeOrTermParamClauses(ParamOwner.Def, numLeadParams) else val tparams = typeParamClauseOpt(ParamOwner.Def) val vparamss = termParamClauses(ParamOwner.Def, numLeadParams) - joinParams(tparams, vparamss) var tpt = fromWithinReturnType { typedOpt() } diff --git a/docs/_docs/reference/experimental/generalized-method-syntax.md b/docs/_docs/reference/other-new-features/generalized-method-syntax.md similarity index 92% rename from docs/_docs/reference/experimental/generalized-method-syntax.md rename to docs/_docs/reference/other-new-features/generalized-method-syntax.md index 072052c1ae10..2dd537cacdd8 100644 --- a/docs/_docs/reference/experimental/generalized-method-syntax.md +++ b/docs/_docs/reference/other-new-features/generalized-method-syntax.md @@ -1,15 +1,9 @@ --- layout: doc-page title: "Generalized Method Syntax" -nightlyOf: https://docs.scala-lang.org/scala3/reference/experimental/generalized-method-syntax.html +nightlyOf: https://docs.scala-lang.org/scala3/reference/other-new-features/generalized-method-syntax.html --- -This feature is not yet part of the Scala 3 language definition. It can be made available by a language import: - -```scala -import scala.language.experimental.clauseInterleaving -``` - The inclusion of using clauses is not the only way in which methods have been updated, type parameter clauses are now allowed in any number and at any position. ## Syntax Changes @@ -51,7 +45,7 @@ trait DB { } ``` -Note that simply replacing `V` by `k.Value` would not be equivalent. For example, if `k.Value` is `Some[Int]`, only the above allows: +Note that simply replacing `V` by `k.Value` would not be equivalent. For example, if `k.Value` is `Some[Int]`, only the above allows: `getOrElse(k)[Option[Int]](None)`, which returns a `Number`. ## Details diff --git a/library/src/scala/runtime/stdLibPatches/language.scala b/library/src/scala/runtime/stdLibPatches/language.scala index d89bd9dcf72e..6272970ab0ed 100644 --- a/library/src/scala/runtime/stdLibPatches/language.scala +++ b/library/src/scala/runtime/stdLibPatches/language.scala @@ -67,6 +67,7 @@ object language: * @see [[https://github.com/scala/improvement-proposals/blob/main/content/clause-interleaving.md]] */ @compileTimeOnly("`clauseInterleaving` can only be used at compile time in import statements") + @deprecated("`clauseInterleaving` is now standard, no language import is needed", since = "3.6") object clauseInterleaving /** Experimental support for pure function type syntax diff --git a/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpInterleavingSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpInterleavingSuite.scala index 15546d086033..735a2eb13fab 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpInterleavingSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpInterleavingSuite.scala @@ -8,9 +8,6 @@ import java.nio.file.Path class SignatureHelpInterleavingSuite extends BaseSignatureHelpSuite: - override protected def scalacOptions(classpath: Seq[Path]): Seq[String] = - List("-language:experimental.clauseInterleaving") - @Test def `proper-position-1` = check( """ diff --git a/scaladoc-testcases/src/tests/extensionParams.scala b/scaladoc-testcases/src/tests/extensionParams.scala index 0e2225d8aa3c..12850778c793 100644 --- a/scaladoc-testcases/src/tests/extensionParams.scala +++ b/scaladoc-testcases/src/tests/extensionParams.scala @@ -61,8 +61,6 @@ extension (using Unit)(a: Int) def f14(): Any = ??? -import scala.language.experimental.clauseInterleaving - extension (using String)(using Int)(a: Animal)(using Unit)(using Number) def f16(b: Any)[T](c: T): T = ??? diff --git a/scaladoc-testcases/src/tests/methodsAndConstructors.scala b/scaladoc-testcases/src/tests/methodsAndConstructors.scala index cddd0f56e9fe..b4c354d174c4 100644 --- a/scaladoc-testcases/src/tests/methodsAndConstructors.scala +++ b/scaladoc-testcases/src/tests/methodsAndConstructors.scala @@ -1,7 +1,5 @@ package tests.methodsAndConstructors -import scala.language.experimental.clauseInterleaving - class A class B extends A class C diff --git a/tests/neg/interleaving-ab.scala b/tests/neg/interleaving-ab.scala index e446626a2982..afdb2f0a192f 100644 --- a/tests/neg/interleaving-ab.scala +++ b/tests/neg/interleaving-ab.scala @@ -1,11 +1,10 @@ -import scala.language.experimental.clauseInterleaving object Ab: given String = "" given Double = 0 def illegal[A][B](x: A)(using B): B = summon[B] // error: Type parameter lists must be separated by a term or using parameter list - + def ab[A](x: A)[B](using B): B = summon[B] def test = ab[Int](0: Int) // error diff --git a/tests/neg/interleaving-params.scala b/tests/neg/interleaving-params.scala index dc6762cf0214..20f6bbb98d3d 100644 --- a/tests/neg/interleaving-params.scala +++ b/tests/neg/interleaving-params.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving class Params{ def bar[T](x: T)[T]: String = ??? // error diff --git a/tests/neg/interleaving-signatureCollision.scala b/tests/neg/interleaving-signatureCollision.scala index a6a729ed3b62..096073e7bda8 100644 --- a/tests/neg/interleaving-signatureCollision.scala +++ b/tests/neg/interleaving-signatureCollision.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object signatureCollision: def f[T](x: T)[U](y: U) = (x,y) diff --git a/tests/neg/interleaving-typeApply.check b/tests/neg/interleaving-typeApply.check index a50c1455bfbb..ca2ab6fa3f3e 100644 --- a/tests/neg/interleaving-typeApply.check +++ b/tests/neg/interleaving-typeApply.check @@ -1,29 +1,29 @@ --- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:10:11 -------------------------------------------- -10 | f3[String]() // error - | ^ - | Type argument String does not conform to upper bound Int - | - | longer explanation available when compiling with `-explain` --- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:11:16 -------------------------------------------- -11 | f5[Int][Unit] // error +-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:9:11 --------------------------------------------- +9 | f3[String]() // error + | ^ + | Type argument String does not conform to upper bound Int + | + | longer explanation available when compiling with `-explain` +-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:10:16 -------------------------------------------- +10 | f5[Int][Unit] // error | ^ | Type argument Unit does not conform to upper bound String | | longer explanation available when compiling with `-explain` --- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:12:19 -------------------------------------------- -12 | f5[String][Unit] // error // error +-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:11:19 -------------------------------------------- +11 | f5[String][Unit] // error // error | ^ | Type argument Unit does not conform to upper bound String | | longer explanation available when compiling with `-explain` --- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:12:11 -------------------------------------------- -12 | f5[String][Unit] // error // error +-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:11:11 -------------------------------------------- +11 | f5[String][Unit] // error // error | ^ | Type argument String does not conform to upper bound Int | | longer explanation available when compiling with `-explain` --- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:13:11 -------------------------------------------- -13 | f7[String]()[Unit] // error +-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:12:11 -------------------------------------------- +12 | f7[String]()[Unit] // error | ^ | Type argument String does not conform to upper bound Int | diff --git a/tests/neg/interleaving-typeApply.scala b/tests/neg/interleaving-typeApply.scala index ad21fe2f0329..5ad6e3dc148e 100644 --- a/tests/neg/interleaving-typeApply.scala +++ b/tests/neg/interleaving-typeApply.scala @@ -1,7 +1,6 @@ -import scala.language.experimental.clauseInterleaving object typeApply: - + def f3[T <: Int](using DummyImplicit)[U <: String](): T => T = ??? def f5[T <: Int](using DummyImplicit)[U <: String]: [X <: Unit] => X => X = ??? def f7[T <: Int](using DummyImplicit)[U <: String]()[X <: Unit]: X => X = ??? diff --git a/tests/neg/interleaving-unmatched.scala b/tests/neg/interleaving-unmatched.scala index 2ce3074d07fa..3a4371798a50 100644 --- a/tests/neg/interleaving-unmatched.scala +++ b/tests/neg/interleaving-unmatched.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object unmatched: def f1[T (x: T)] = ??? // error diff --git a/tests/neg/interleavingExperimental.check b/tests/neg/interleavingExperimental.check new file mode 100644 index 000000000000..a5e10506bdc3 --- /dev/null +++ b/tests/neg/interleavingExperimental.check @@ -0,0 +1,4 @@ +-- [E040] Syntax Error: tests/neg/interleavingExperimental.scala:3:15 -------------------------------------------------- +3 |def ba[A](x: A)[B](using B): B = summon[B] // error: clauseInterleaving was experimental until 3.6 + | ^ + | '=' expected, but '[' found diff --git a/tests/neg/interleavingExperimental.scala b/tests/neg/interleavingExperimental.scala new file mode 100644 index 000000000000..ed13707fcb68 --- /dev/null +++ b/tests/neg/interleavingExperimental.scala @@ -0,0 +1,3 @@ +//> using options --source 3.5 + +def ba[A](x: A)[B](using B): B = summon[B] // error: clauseInterleaving was experimental until 3.6 diff --git a/tests/neg/namedTypeParams.check b/tests/neg/namedTypeParams.check index 5e0672f20f25..f203f482d117 100644 --- a/tests/neg/namedTypeParams.check +++ b/tests/neg/namedTypeParams.check @@ -92,11 +92,11 @@ | illegal repeated type application | You might have meant something like: | Test.f[Y = String, Int] --- [E102] Syntax Error: tests/neg/namedTypeParams.scala:33:9 ----------------------------------------------------------- -33 | f2[Y = String][X = Int](1, "") // error: Y is undefined +-- [E102] Syntax Error: tests/neg/namedTypeParams.scala:32:9 ----------------------------------------------------------- +32 | f2[Y = String][X = Int](1, "") // error: Y is undefined | ^^^^^^ | Type parameter Y is undefined. Expected one of X. --- [E102] Syntax Error: tests/neg/namedTypeParams.scala:34:9 ----------------------------------------------------------- -34 | f2[Y = String](1, "") // error: Y is undefined +-- [E102] Syntax Error: tests/neg/namedTypeParams.scala:33:9 ----------------------------------------------------------- +33 | f2[Y = String](1, "") // error: Y is undefined | ^^^^^^ | Type parameter Y is undefined. Expected one of X. diff --git a/tests/neg/namedTypeParams.scala b/tests/neg/namedTypeParams.scala index 53ef14188e12..489ac1e8cdb6 100644 --- a/tests/neg/namedTypeParams.scala +++ b/tests/neg/namedTypeParams.scala @@ -27,7 +27,6 @@ object Test: object TestInterleaving: import language.experimental.namedTypeArguments - import language.experimental.clauseInterleaving def f2[X](using DummyImplicit)[Y](x: X, y: Y): Int = ??? f2[Y = String][X = Int](1, "") // error: Y is undefined diff --git a/tests/neg/overrides.scala b/tests/neg/overrides.scala index 8016f5646d09..c8f577103a6a 100644 --- a/tests/neg/overrides.scala +++ b/tests/neg/overrides.scala @@ -44,8 +44,6 @@ class A[T] { def next: T = ??? - import scala.language.experimental.clauseInterleaving - def b[U <: T](x: Int)[V >: T](y: String) = false } @@ -57,8 +55,6 @@ class B extends A[Int] { override def next(): Int = ??? // error: incompatible type - import scala.language.experimental.clauseInterleaving - override def b[T <: Int](x: Int)(y: String) = true // error } @@ -68,8 +64,6 @@ class C extends A[String] { override def next: Int = ??? // error: incompatible type - import scala.language.experimental.clauseInterleaving - override def b[T <: String](x: Int)[U >: Int](y: String) = true // error: incompatible type } diff --git a/tests/pos/interleaving-ba.scala b/tests/pos/interleaving-ba.scala index 69fe2d9537a0..4a7d721c804e 100644 --- a/tests/pos/interleaving-ba.scala +++ b/tests/pos/interleaving-ba.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object BA { given String = "" diff --git a/tests/pos/interleaving-chainedParams.scala b/tests/pos/interleaving-chainedParams.scala index a54885d28002..02dc7a5ccc9c 100644 --- a/tests/pos/interleaving-chainedParams.scala +++ b/tests/pos/interleaving-chainedParams.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object chainedParams{ diff --git a/tests/pos/interleaving-classless.scala b/tests/pos/interleaving-classless.scala index 5aec92db3409..bddfc821385d 100644 --- a/tests/pos/interleaving-classless.scala +++ b/tests/pos/interleaving-classless.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving def f1[T]()[U](x: T, y: U): (T, U) = (x, y) def f2[T](x: T)[U](y: U): (T, U) = (x, y) diff --git a/tests/pos/interleaving-functor.scala b/tests/pos/interleaving-functor.scala index 35bed59f77f0..b588e35f60a2 100644 --- a/tests/pos/interleaving-functor.scala +++ b/tests/pos/interleaving-functor.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object functorInterleaving: //taken from https://dotty.epfl.ch/docs/reference/contextual/type-classes.html diff --git a/tests/pos/interleaving-newline.scala b/tests/pos/interleaving-newline.scala index de8fb98a2f81..d71bdc910de2 100644 --- a/tests/pos/interleaving-newline.scala +++ b/tests/pos/interleaving-newline.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object newline { def multipleLines diff --git a/tests/pos/interleaving-overload.scala b/tests/pos/interleaving-overload.scala index 1902551f9036..e1c3db1abe37 100644 --- a/tests/pos/interleaving-overload.scala +++ b/tests/pos/interleaving-overload.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving class A{ diff --git a/tests/pos/interleaving-params.scala b/tests/pos/interleaving-params.scala index 36963ff2e123..b12608f4b291 100644 --- a/tests/pos/interleaving-params.scala +++ b/tests/pos/interleaving-params.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving class Params{ type U diff --git a/tests/pos/interleaving-signatureCollision.scala b/tests/pos/interleaving-signatureCollision.scala index 77190284ae6d..be016e7bdbfe 100644 --- a/tests/pos/interleaving-signatureCollision.scala +++ b/tests/pos/interleaving-signatureCollision.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving import scala.annotation.targetName object signatureCollision: diff --git a/tests/pos/interleaving-typeApply.scala b/tests/pos/interleaving-typeApply.scala index 3c669cc76bfc..d8a7fd5d2ec1 100644 --- a/tests/pos/interleaving-typeApply.scala +++ b/tests/pos/interleaving-typeApply.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object typeApply: @@ -12,7 +11,6 @@ object typeApply: def f7[T <: Int](using DummyImplicit)[U <: String]()[X <: Unit]: X => X = ??? @main def test = { - import scala.language.experimental.namedTypeArguments f0[Int][String] f1[Int][String] f2[Int][String]() diff --git a/tests/pos/interleavingExperimental.scala b/tests/pos/interleavingExperimental.scala new file mode 100644 index 000000000000..63227ef1ebfe --- /dev/null +++ b/tests/pos/interleavingExperimental.scala @@ -0,0 +1,5 @@ +//> using options --source 3.5 + +import scala.language.experimental.clauseInterleaving + +def ba[A](x: A)[B](using B): B = summon[B] \ No newline at end of file diff --git a/tests/pos/namedTypeParams.scala b/tests/pos/namedTypeParams.scala index 388bcfa98bef..d538bef52a69 100644 --- a/tests/pos/namedTypeParams.scala +++ b/tests/pos/namedTypeParams.scala @@ -11,7 +11,6 @@ object Test { } object TestInterleaving{ - import language.experimental.clauseInterleaving def f2[X](using DummyImplicit)[Y](x: X, y: Y): Int = ??? f2[X = Int][Y = String](1, "") diff --git a/tests/pos/overrides.scala b/tests/pos/overrides.scala index c3b6235d7c1f..e56c4c941a7f 100644 --- a/tests/pos/overrides.scala +++ b/tests/pos/overrides.scala @@ -4,8 +4,6 @@ class A[T] { def f(x: T)(y: T = x) = y - import scala.language.experimental.clauseInterleaving - def b[U <: T](x: Int)[V >: T](y: String) = false } @@ -15,9 +13,6 @@ class B extends A[Int] { f(2)() - - import scala.language.experimental.clauseInterleaving - override def b[T <: Int](x: Int)[U >: Int](y: String) = true } diff --git a/tests/run/interleaving.scala b/tests/run/interleaving.scala index 6749e59168bc..cc52528486b1 100644 --- a/tests/run/interleaving.scala +++ b/tests/run/interleaving.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.clauseInterleaving object Test extends App { trait Key { type Value }