diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index 91f228bca560..30e6afb5d7f9 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -33,7 +33,6 @@ object Feature: val pureFunctions = experimental("pureFunctions") val captureChecking = experimental("captureChecking") val into = experimental("into") - val namedTuples = experimental("namedTuples") val modularity = experimental("modularity") val betterMatchTypeExtractors = experimental("betterMatchTypeExtractors") val quotedPatternsWithPolymorphicFunctions = experimental("quotedPatternsWithPolymorphicFunctions") @@ -64,7 +63,6 @@ object Feature: (pureFunctions, "Enable pure functions for capture checking"), (captureChecking, "Enable experimental capture checking"), (into, "Allow into modifier on parameter types"), - (namedTuples, "Allow named tuples"), (modularity, "Enable experimental modularity features"), (betterMatchTypeExtractors, "Enable better match type extractors"), (betterFors, "Enable improvements in `for` comprehensions") diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index cfb132dd95ce..831a6021020f 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -671,7 +671,7 @@ object Parsers { else leading :: Nil def maybeNamed(op: () => Tree): () => Tree = () => - if isIdent && in.lookahead.token == EQUALS && in.featureEnabled(Feature.namedTuples) then + if isIdent && in.lookahead.token == EQUALS && sourceVersion.enablesNamedTuples then atSpan(in.offset): val name = ident() in.nextToken() @@ -1160,6 +1160,13 @@ object Parsers { patch(source, infixOp.span, asApply.show(using ctx.withoutColors)) asApply // allow to use pre-3.6 syntax in migration mode else infixOp + case Parens(assign @ Assign(ident, value)) if !isNamedTupleOperator => + report.errorOrMigrationWarning(DeprecatedInfixNamedArgumentSyntax(), infixOp.right.srcPos, MigrationVersion.AmbiguousNamedTupleSyntax) + if MigrationVersion.AmbiguousNamedTupleSyntax.needsPatch then + val asApply = cpy.Apply(infixOp)(Select(opInfo.operand, opInfo.operator.name), assign :: Nil) + patch(source, infixOp.span, asApply.show(using ctx.withoutColors)) + asApply // allow to use pre-3.6 syntax in migration mode + else infixOp case _ => infixOp } @@ -2177,7 +2184,7 @@ object Parsers { if namedOK && isIdent && in.lookahead.token == EQUALS then commaSeparated(() => namedArgType()) - else if tupleOK && isIdent && in.lookahead.isColon && in.featureEnabled(Feature.namedTuples) then + else if tupleOK && isIdent && in.lookahead.isColon && sourceVersion.enablesNamedTuples then commaSeparated(() => namedElem()) else commaSeparated(() => argType()) diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index b321ed35a23f..b5d67f0808b2 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -3362,7 +3362,7 @@ end QuotedTypeMissing final class DeprecatedAssignmentSyntax(key: Name, value: untpd.Tree)(using Context) extends SyntaxMsg(DeprecatedAssignmentSyntaxID): override protected def msg(using Context): String = - i"""Deprecated syntax: in the future it would be interpreted as a named tuple with one element, + i"""Deprecated syntax: since 3.7 this is interpreted as a named tuple with one element, |not as an assignment. | |To assign a value, use curly braces: `{${key} = ${value}}`.""" @@ -3372,9 +3372,9 @@ final class DeprecatedAssignmentSyntax(key: Name, value: untpd.Tree)(using Conte class DeprecatedInfixNamedArgumentSyntax()(using Context) extends SyntaxMsg(DeprecatedInfixNamedArgumentSyntaxID): def msg(using Context) = - i"""Deprecated syntax: infix named arguments lists are deprecated; in the future it would be interpreted as a single name tuple argument. + i"""Deprecated syntax: infix named arguments lists are deprecated; since 3.7 it is interpreted as a single name tuple argument. |To avoid this warning, either remove the argument names or use dotted selection.""" - + Message.rewriteNotice("This", version = SourceVersion.`3.6-migration`) + + Message.rewriteNotice("This", version = SourceVersion.`3.7-migration`) def explain(using Context) = "" diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 2179fae8cb3f..dd4b0db5a4d9 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -825,7 +825,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer def tryNamedTupleSelection() = val namedTupleElems = qual.tpe.widenDealias.namedTupleElementTypes(true) val nameIdx = namedTupleElems.indexWhere(_._1 == selName) - if nameIdx >= 0 && Feature.enabled(Feature.namedTuples) then + if nameIdx >= 0 && sourceVersion.enablesNamedTuples then typed( untpd.Apply( untpd.Select(untpd.TypedSplice(qual), nme.apply), @@ -3500,19 +3500,22 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer /** Checks if `tree` is a named tuple with one element that could be * interpreted as an assignment, such as `(x = 1)`. If so, issues a warning. */ - def checkDeprecatedAssignmentSyntax(tree: untpd.Tuple)(using Context): Unit = - tree.trees match - case List(NamedArg(name, value)) => + def checkDeprecatedAssignmentSyntax(tree: untpd.Tuple | untpd.Parens)(using Context): Unit = + val assignmentArgs = tree match { + case untpd.Tuple(List(NamedArg(name, value))) => val tmpCtx = ctx.fresh.setNewTyperState() typedAssign(untpd.Assign(untpd.Ident(name), value), WildcardType)(using tmpCtx) - if !tmpCtx.reporter.hasErrors then - // If there are no errors typing the above, then the named tuple is - // ambiguous and we issue a warning. - report.migrationWarning(DeprecatedAssignmentSyntax(name, value), tree.srcPos) - if MigrationVersion.AmbiguousNamedTupleSyntax.needsPatch then - patch(tree.source, Span(tree.span.start, tree.span.start + 1), "{") - patch(tree.source, Span(tree.span.end - 1, tree.span.end), "}") - case _ => () + Option.unless(tmpCtx.reporter.hasErrors)(name -> value) + case untpd.Parens(Assign(ident: untpd.Ident, value)) => Some(ident.name -> value) + case _ => None + } + assignmentArgs.foreach: (name, value) => + // If there are no errors typing the above, then the named tuple is + // ambiguous and we issue a warning. + report.migrationWarning(DeprecatedAssignmentSyntax(name, value), tree.srcPos) + if MigrationVersion.AmbiguousNamedTupleSyntax.needsPatch then + patch(tree.source, Span(tree.span.start, tree.span.start + 1), "{") + patch(tree.source, Span(tree.span.end - 1, tree.span.end), "}") /** Retrieve symbol attached to given tree */ protected def retrieveSym(tree: untpd.Tree)(using Context): Symbol = tree.removeAttachment(SymOfTree) match { @@ -3621,6 +3624,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer case tree: untpd.SplicePattern => typedSplicePattern(tree, pt) case tree: untpd.MacroTree => report.error("Unexpected macro", tree.srcPos); tpd.nullLiteral // ill-formed code may reach here case tree: untpd.Hole => typedHole(tree, pt) + case tree: untpd.Parens => + checkDeprecatedAssignmentSyntax(tree) + typedUnadapted(desugar(tree, pt), pt, locked) case _ => typedUnadapted(desugar(tree, pt), pt, locked) } diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 55d26130343b..e62c80d7bff7 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -79,7 +79,7 @@ class CompilationTests { compileFile("tests/rewrites/i20002.scala", defaultOptions.and("-indent", "-rewrite")), compileDir("tests/rewrites/annotation-named-pararamters", defaultOptions.and("-rewrite", "-source:3.6-migration")), compileFile("tests/rewrites/i21418.scala", unindentOptions.and("-rewrite", "-source:3.5-migration")), - compileFile("tests/rewrites/infix-named-args.scala", defaultOptions.and("-rewrite", "-source:3.6-migration")), + compileFile("tests/rewrites/infix-named-args.scala", defaultOptions.and("-rewrite", "-source:3.7-migration")), compileFile("tests/rewrites/ambiguous-named-tuple-assignment.scala", defaultOptions.and("-rewrite", "-source:3.6-migration")), compileFile("tests/rewrites/i21382.scala", defaultOptions.and("-indent", "-rewrite")), compileFile("tests/rewrites/unused.scala", defaultOptions.and("-rewrite", "-Wunused:all")), diff --git a/docs/_docs/reference/experimental/named-tuples.md b/docs/_docs/reference/other-new-features/named-tuples.md similarity index 98% rename from docs/_docs/reference/experimental/named-tuples.md rename to docs/_docs/reference/other-new-features/named-tuples.md index 27d74259725d..0d1145e83ba2 100644 --- a/docs/_docs/reference/experimental/named-tuples.md +++ b/docs/_docs/reference/other-new-features/named-tuples.md @@ -1,10 +1,11 @@ --- layout: doc-page title: "Named Tuples" -nightlyOf: https://docs.scala-lang.org/scala3/reference/experimental/named-tuples.html +nightlyOf: https://docs.scala-lang.org/scala3/reference/other-new-features/named-tuples.html --- -The elements of a tuple can now be named. Example: +Starting in Scala 3.7, the elements of a tuple can be named. +Example: ```scala type Person = (name: String, age: Int) val Bob: Person = (name = "Bob", age = 33) diff --git a/docs/sidebar.yml b/docs/sidebar.yml index edfa86554d7f..af6587bded44 100644 --- a/docs/sidebar.yml +++ b/docs/sidebar.yml @@ -72,6 +72,7 @@ subsection: - page: reference/other-new-features/export.md - page: reference/other-new-features/opaques.md - page: reference/other-new-features/opaques-details.md + - page: reference/other-new-features/named-tuples.md - page: reference/other-new-features/open-classes.md - page: reference/other-new-features/parameter-untupling.md - page: reference/other-new-features/parameter-untupling-spec.md @@ -158,7 +159,6 @@ subsection: - page: reference/experimental/cc.md - page: reference/experimental/purefuns.md - page: reference/experimental/tupled-function.md - - page: reference/experimental/named-tuples.md - page: reference/experimental/modularity.md - page: reference/experimental/typeclasses.md - page: reference/experimental/runtimeChecked.md diff --git a/language-server/test/dotty/tools/languageserver/CompletionTest.scala b/language-server/test/dotty/tools/languageserver/CompletionTest.scala index 38deb4c40c0f..8f05d6ad11da 100644 --- a/language-server/test/dotty/tools/languageserver/CompletionTest.scala +++ b/language-server/test/dotty/tools/languageserver/CompletionTest.scala @@ -1725,8 +1725,7 @@ class CompletionTest { .completion(m6, Set()) @Test def namedTupleCompletion: Unit = - code"""|import scala.language.experimental.namedTuples - | + code"""| |val person: (name: String, city: String) = | (name = "Jamie", city = "Lausanne") | diff --git a/library/src/scala/NamedTuple.scala b/library/src/scala/NamedTuple.scala index 0d1deffce513..1e4d3c084a3c 100644 --- a/library/src/scala/NamedTuple.scala +++ b/library/src/scala/NamedTuple.scala @@ -1,8 +1,6 @@ package scala -import annotation.experimental import compiletime.ops.boolean.* -@experimental object NamedTuple: /** The type to which named tuples get mapped to. For instance, @@ -133,7 +131,6 @@ object NamedTuple: end NamedTuple /** Separate from NamedTuple object so that we can match on the opaque type NamedTuple. */ -@experimental object NamedTupleDecomposition: import NamedTuple.* extension [N <: Tuple, V <: Tuple](x: NamedTuple[N, V]) diff --git a/library/src/scala/runtime/stdLibPatches/language.scala b/library/src/scala/runtime/stdLibPatches/language.scala index fc7082698f21..9204b4d6e450 100644 --- a/library/src/scala/runtime/stdLibPatches/language.scala +++ b/library/src/scala/runtime/stdLibPatches/language.scala @@ -97,6 +97,7 @@ object language: * @see [[https://dotty.epfl.ch/docs/reference/experimental/named-tuples]] */ @compileTimeOnly("`namedTuples` can only be used at compile time in import statements") + @deprecated("The experimental.namedTuples language import is no longer needed since the feature is now standard", since = "3.7") object namedTuples /** Experimental support for new features for better modularity, including diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala index f3fc03b3fb33..e9f58ee45df8 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala @@ -2032,8 +2032,7 @@ class CompletionSuite extends BaseCompletionSuite: @Test def `namedTuple completions` = check( - """|import scala.language.experimental.namedTuples - |import scala.NamedTuple.* + """|import scala.NamedTuple.* | |val person = (name = "Jamie", city = "Lausanne") | @@ -2044,8 +2043,7 @@ class CompletionSuite extends BaseCompletionSuite: @Test def `Selectable with namedTuple Fields member` = check( - """|import scala.language.experimental.namedTuples - |import scala.NamedTuple.* + """|import scala.NamedTuple.* | |class NamedTupleSelectable extends Selectable { | type Fields <: AnyNamedTuple diff --git a/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala index ff4c6ec25e27..3fb97aaeca4e 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/definition/PcDefinitionSuite.scala @@ -507,8 +507,7 @@ class PcDefinitionSuite extends BasePcDefinitionSuite: @Test def `named-tuples` = check( - """|import scala.language.experimental.namedTuples - | + """| |val <> = (name = "Bob", age = 42, height = 1.9d) |val foo_name = foo.na@@me |""".stripMargin diff --git a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala index ba77e2b16cdc..8ed8c022cc3d 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/hover/HoverTermSuite.scala @@ -720,8 +720,7 @@ class HoverTermSuite extends BaseHoverSuite: @Test def `named-tuples`: Unit = check( - """import scala.language.experimental.namedTuples - | + """ |val foo = (name = "Bob", age = 42, height = 1.9d) |val foo_name = foo.na@@me |""".stripMargin, @@ -730,9 +729,7 @@ class HoverTermSuite extends BaseHoverSuite: @Test def `named-tuples2`: Unit = check( - """|import scala.language.experimental.namedTuples - | - |import NamedTuple.* + """|import NamedTuple.* | |class NamedTupleSelectable extends Selectable { | type Fields <: AnyNamedTuple diff --git a/tests/neg/i20517.check b/tests/neg/i20517.check index 55aeff46572b..119c34025ee0 100644 --- a/tests/neg/i20517.check +++ b/tests/neg/i20517.check @@ -1,7 +1,7 @@ --- [E007] Type Mismatch Error: tests/neg/i20517.scala:10:43 ------------------------------------------------------------ -10 | def dep(foo: Foo[Any]): From[foo.type] = (elem = "") // error - | ^^^^^^^^^^^ - | Found: (elem : String) - | Required: NamedTuple.From[(foo : Foo[Any])] - | - | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg/i20517.scala:9:43 ------------------------------------------------------------- +9 | def dep(foo: Foo[Any]): From[foo.type] = (elem = "") // error + | ^^^^^^^^^^^ + | Found: (elem : String) + | Required: NamedTuple.From[(foo : Foo[Any])] + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i20517.scala b/tests/neg/i20517.scala index 11c4432434dd..342a7d86ca7e 100644 --- a/tests/neg/i20517.scala +++ b/tests/neg/i20517.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.namedTuples import NamedTuple.From case class Foo[+T](elem: T) diff --git a/tests/neg/i22192.check b/tests/neg/i22192.check index 35ed426ccb11..77dffb4ae56a 100644 --- a/tests/neg/i22192.check +++ b/tests/neg/i22192.check @@ -1,30 +1,30 @@ --- Error: tests/neg/i22192.scala:6:12 ---------------------------------------------------------------------------------- -6 | case City(iam = n, confused = p) => // error // error +-- Error: tests/neg/i22192.scala:4:12 ---------------------------------------------------------------------------------- +4 | case City(iam = n, confused = p) => // error // error | ^^^^^^^ | No element named `iam` is defined in selector type City --- Error: tests/neg/i22192.scala:6:21 ---------------------------------------------------------------------------------- -6 | case City(iam = n, confused = p) => // error // error +-- Error: tests/neg/i22192.scala:4:21 ---------------------------------------------------------------------------------- +4 | case City(iam = n, confused = p) => // error // error | ^^^^^^^^^^^^ | No element named `confused` is defined in selector type City --- [E006] Not Found Error: tests/neg/i22192.scala:7:7 ------------------------------------------------------------------ -7 | s"$n has a population of $p" // error // error +-- [E006] Not Found Error: tests/neg/i22192.scala:5:7 ------------------------------------------------------------------ +5 | s"$n has a population of $p" // error // error | ^ | Not found: n | | longer explanation available when compiling with `-explain` --- [E006] Not Found Error: tests/neg/i22192.scala:7:30 ----------------------------------------------------------------- -7 | s"$n has a population of $p" // error // error +-- [E006] Not Found Error: tests/neg/i22192.scala:5:30 ----------------------------------------------------------------- +5 | s"$n has a population of $p" // error // error | ^ | Not found: p | | longer explanation available when compiling with `-explain` --- Error: tests/neg/i22192.scala:10:12 --------------------------------------------------------------------------------- -10 | case Some(iam = n) => // error - | ^^^^^^^ - | No element named `iam` is defined in selector type City --- [E006] Not Found Error: tests/neg/i22192.scala:11:4 ----------------------------------------------------------------- -11 | n // error - | ^ - | Not found: n - | - | longer explanation available when compiling with `-explain` +-- Error: tests/neg/i22192.scala:8:12 ---------------------------------------------------------------------------------- +8 | case Some(iam = n) => // error + | ^^^^^^^ + | No element named `iam` is defined in selector type City +-- [E006] Not Found Error: tests/neg/i22192.scala:9:4 ------------------------------------------------------------------ +9 | n // error + | ^ + | Not found: n + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i22192.scala b/tests/neg/i22192.scala index 16eeb643dee0..4f7fd77eaf6c 100644 --- a/tests/neg/i22192.scala +++ b/tests/neg/i22192.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - case class City(name: String, population: Int) def getCityInfo(city: City) = city match diff --git a/tests/neg/i22192a.check b/tests/neg/i22192a.check index 8bfbcb127c54..7f973813c46c 100644 --- a/tests/neg/i22192a.check +++ b/tests/neg/i22192a.check @@ -1,19 +1,19 @@ --- Error: tests/neg/i22192a.scala:6:12 --------------------------------------------------------------------------------- -6 | case Some(iam = n) => // error +-- Error: tests/neg/i22192a.scala:4:12 --------------------------------------------------------------------------------- +4 | case Some(iam = n) => // error | ^^^^^^^ | No element named `iam` is defined in selector type (name : String) --- [E006] Not Found Error: tests/neg/i22192a.scala:7:4 ----------------------------------------------------------------- -7 | n // error +-- [E006] Not Found Error: tests/neg/i22192a.scala:5:4 ----------------------------------------------------------------- +5 | n // error | ^ | Not found: n | | longer explanation available when compiling with `-explain` --- Error: tests/neg/i22192a.scala:11:12 -------------------------------------------------------------------------------- -11 | case Some(iam = n) => // error - | ^^^^^^^ - | No element named `iam` is defined in selector type (name : String, population : Int) --- [E006] Not Found Error: tests/neg/i22192a.scala:12:4 ---------------------------------------------------------------- -12 | n // error +-- Error: tests/neg/i22192a.scala:9:12 --------------------------------------------------------------------------------- +9 | case Some(iam = n) => // error + | ^^^^^^^ + | No element named `iam` is defined in selector type (name : String, population : Int) +-- [E006] Not Found Error: tests/neg/i22192a.scala:10:4 ---------------------------------------------------------------- +10 | n // error | ^ | Not found: n | diff --git a/tests/neg/i22192a.scala b/tests/neg/i22192a.scala index 6460e613d517..12d41f06b19f 100644 --- a/tests/neg/i22192a.scala +++ b/tests/neg/i22192a.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - type City = (name: String) def getCityInfo(city: Option[City]) = city match diff --git a/tests/neg/infix-named-args.check b/tests/neg/infix-named-args.check index d960892a9624..d9b7998f4dec 100644 --- a/tests/neg/infix-named-args.check +++ b/tests/neg/infix-named-args.check @@ -1,5 +1,5 @@ --- [E134] Type Error: tests/neg/infix-named-args.scala:4:13 ------------------------------------------------------------ -4 | def f = 42 + (x = 1) // error // werror +-- [E134] Type Error: tests/neg/infix-named-args.scala:2:13 ------------------------------------------------------------ +2 | def f = 42 + (x = 1) // error // werror | ^^^^ | None of the overloaded alternatives of method + in class Int with types | (x: Double): Double @@ -11,27 +11,27 @@ | (x: Byte): Int | (x: String): String | match arguments ((x : Int)) (a named tuple) --- [E204] Syntax Warning: tests/neg/infix-named-args.scala:4:15 -------------------------------------------------------- -4 | def f = 42 + (x = 1) // error // werror +-- [E204] Syntax Warning: tests/neg/infix-named-args.scala:2:15 -------------------------------------------------------- +2 | def f = 42 + (x = 1) // error // werror | ^^^^^^^ - |Deprecated syntax: infix named arguments lists are deprecated; in the future it would be interpreted as a single name tuple argument. + |Deprecated syntax: infix named arguments lists are deprecated; since 3.7 it is interpreted as a single name tuple argument. |To avoid this warning, either remove the argument names or use dotted selection. - |This can be rewritten automatically under -rewrite -source 3.6-migration. --- [E204] Syntax Warning: tests/neg/infix-named-args.scala:7:26 -------------------------------------------------------- -7 | def g = new C() `multi` (x = 42, y = 27) // werror + |This can be rewritten automatically under -rewrite -source 3.7-migration. +-- [E204] Syntax Warning: tests/neg/infix-named-args.scala:5:26 -------------------------------------------------------- +5 | def g = new C() `multi` (x = 42, y = 27) // werror | ^^^^^^^^^^^^^^^^ - |Deprecated syntax: infix named arguments lists are deprecated; in the future it would be interpreted as a single name tuple argument. + |Deprecated syntax: infix named arguments lists are deprecated; since 3.7 it is interpreted as a single name tuple argument. |To avoid this warning, either remove the argument names or use dotted selection. - |This can be rewritten automatically under -rewrite -source 3.6-migration. --- [E204] Syntax Warning: tests/neg/infix-named-args.scala:8:21 -------------------------------------------------------- -8 | def h = new C() ** (x = 42, y = 27) // werror + |This can be rewritten automatically under -rewrite -source 3.7-migration. +-- [E204] Syntax Warning: tests/neg/infix-named-args.scala:6:21 -------------------------------------------------------- +6 | def h = new C() ** (x = 42, y = 27) // werror | ^^^^^^^^^^^^^^^^ - |Deprecated syntax: infix named arguments lists are deprecated; in the future it would be interpreted as a single name tuple argument. + |Deprecated syntax: infix named arguments lists are deprecated; since 3.7 it is interpreted as a single name tuple argument. |To avoid this warning, either remove the argument names or use dotted selection. - |This can be rewritten automatically under -rewrite -source 3.6-migration. --- [E204] Syntax Warning: tests/neg/infix-named-args.scala:15:18 ------------------------------------------------------- -15 | def f = this ** (x = 2) // werror + |This can be rewritten automatically under -rewrite -source 3.7-migration. +-- [E204] Syntax Warning: tests/neg/infix-named-args.scala:13:18 ------------------------------------------------------- +13 | def f = this ** (x = 2) // werror | ^^^^^^^ - |Deprecated syntax: infix named arguments lists are deprecated; in the future it would be interpreted as a single name tuple argument. + |Deprecated syntax: infix named arguments lists are deprecated; since 3.7 it is interpreted as a single name tuple argument. |To avoid this warning, either remove the argument names or use dotted selection. - |This can be rewritten automatically under -rewrite -source 3.6-migration. + |This can be rewritten automatically under -rewrite -source 3.7-migration. diff --git a/tests/neg/infix-named-args.scala b/tests/neg/infix-named-args.scala index b0ef555cf965..d8616899540c 100644 --- a/tests/neg/infix-named-args.scala +++ b/tests/neg/infix-named-args.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - class C: def f = 42 + (x = 1) // error // werror def multi(x: Int, y: Int): Int = x + y diff --git a/tests/neg/named-tuple-selectable.scala b/tests/neg/named-tuple-selectable.scala index 5cf7e68654ef..c81eba1237ff 100644 --- a/tests/neg/named-tuple-selectable.scala +++ b/tests/neg/named-tuple-selectable.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - class FromFields extends Selectable: type Fields = (i: Int) def selectDynamic(key: String) = diff --git a/tests/neg/named-tuples-2.check b/tests/neg/named-tuples-2.check index 0a52d5f3989b..daa1c0d69069 100644 --- a/tests/neg/named-tuples-2.check +++ b/tests/neg/named-tuples-2.check @@ -1,8 +1,8 @@ --- Error: tests/neg/named-tuples-2.scala:5:9 --------------------------------------------------------------------------- -5 | case (name, age) => () // error +-- Error: tests/neg/named-tuples-2.scala:4:9 --------------------------------------------------------------------------- +4 | case (name, age) => () // error | ^ | this case is unreachable since type (String, Int, Boolean) is not a subclass of class Tuple2 --- Error: tests/neg/named-tuples-2.scala:6:9 --------------------------------------------------------------------------- -6 | case (n, a, m, x) => () // error +-- Error: tests/neg/named-tuples-2.scala:5:9 --------------------------------------------------------------------------- +5 | case (n, a, m, x) => () // error | ^ | this case is unreachable since type (String, Int, Boolean) is not a subclass of class Tuple4 diff --git a/tests/neg/named-tuples-2.scala b/tests/neg/named-tuples-2.scala index 0507891e0549..b3917d9ad57c 100644 --- a/tests/neg/named-tuples-2.scala +++ b/tests/neg/named-tuples-2.scala @@ -1,4 +1,3 @@ -import language.experimental.namedTuples def Test = val person = (name = "Bob", age = 33, married = true) person match diff --git a/tests/neg/named-tuples-3.check b/tests/neg/named-tuples-3.check index 2091c36191c0..2809836b4803 100644 --- a/tests/neg/named-tuples-3.check +++ b/tests/neg/named-tuples-3.check @@ -1,5 +1,5 @@ --- [E007] Type Mismatch Error: tests/neg/named-tuples-3.scala:7:16 ----------------------------------------------------- -7 |val p: Person = f // error +-- [E007] Type Mismatch Error: tests/neg/named-tuples-3.scala:5:16 ----------------------------------------------------- +5 |val p: Person = f // error | ^ | Found: NamedTuple.NamedTuple[(Int, Any), (Int, String)] | Required: Person diff --git a/tests/neg/named-tuples-3.scala b/tests/neg/named-tuples-3.scala index 0f1215338b0a..21e6ed9b3741 100644 --- a/tests/neg/named-tuples-3.scala +++ b/tests/neg/named-tuples-3.scala @@ -1,5 +1,3 @@ -import language.experimental.namedTuples - def f: NamedTuple.NamedTuple[(Int, Any), (Int, String)] = ??? type Person = (name: Int, age: String) diff --git a/tests/neg/named-tuples-mirror.check b/tests/neg/named-tuples-mirror.check index 5c24e37cb2b4..df6d570efa9f 100644 --- a/tests/neg/named-tuples-mirror.check +++ b/tests/neg/named-tuples-mirror.check @@ -1,8 +1,8 @@ --- [E172] Type Error: tests/neg/named-tuples-mirror.scala:6:47 --------------------------------------------------------- -6 | summon[Mirror.SumOf[(foo: Int, bla: String)]] // error +-- [E172] Type Error: tests/neg/named-tuples-mirror.scala:5:47 --------------------------------------------------------- +5 | summon[Mirror.SumOf[(foo: Int, bla: String)]] // error | ^ |No given instance of type scala.deriving.Mirror.SumOf[(foo : Int, bla : String)] was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type scala.deriving.Mirror.SumOf[(foo : Int, bla : String)]: type `(foo : Int, bla : String)` is not a generic sum because named tuples are not sealed classes --- Error: tests/neg/named-tuples-mirror.scala:9:4 ---------------------------------------------------------------------- -9 | }]// error +-- Error: tests/neg/named-tuples-mirror.scala:8:4 ---------------------------------------------------------------------- +8 | }]// error | ^ |MirroredElemLabels mismatch, expected: (("foo" : String), ("bla" : String)), found: (("foo" : String), ("ba" : String)). diff --git a/tests/neg/named-tuples-mirror.scala b/tests/neg/named-tuples-mirror.scala index d78fa104f3c5..381eaf839262 100644 --- a/tests/neg/named-tuples-mirror.scala +++ b/tests/neg/named-tuples-mirror.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.namedTuples import scala.deriving.* import scala.compiletime.* diff --git a/tests/neg/named-tuples.check b/tests/neg/named-tuples.check index db3cc703722f..8ec958b6a75d 100644 --- a/tests/neg/named-tuples.check +++ b/tests/neg/named-tuples.check @@ -1,101 +1,101 @@ --- Error: tests/neg/named-tuples.scala:9:19 ---------------------------------------------------------------------------- -9 | val illformed = (_2 = 2) // error +-- Error: tests/neg/named-tuples.scala:8:19 ---------------------------------------------------------------------------- +8 | val illformed = (_2 = 2) // error | ^^^^^^ | _2 cannot be used as the name of a tuple element because it is a regular tuple selector --- Error: tests/neg/named-tuples.scala:10:20 --------------------------------------------------------------------------- -10 | type Illformed = (_1: Int) // error - | ^^^^^^^ - | _1 cannot be used as the name of a tuple element because it is a regular tuple selector --- Error: tests/neg/named-tuples.scala:11:40 --------------------------------------------------------------------------- -11 | val illformed2 = (name = "", age = 0, name = true) // error +-- Error: tests/neg/named-tuples.scala:9:20 ---------------------------------------------------------------------------- +9 | type Illformed = (_1: Int) // error + | ^^^^^^^ + | _1 cannot be used as the name of a tuple element because it is a regular tuple selector +-- Error: tests/neg/named-tuples.scala:10:40 --------------------------------------------------------------------------- +10 | val illformed2 = (name = "", age = 0, name = true) // error | ^^^^^^^^^^^ | Duplicate tuple element name --- Error: tests/neg/named-tuples.scala:12:45 --------------------------------------------------------------------------- -12 | type Illformed2 = (name: String, age: Int, name: Boolean) // error +-- Error: tests/neg/named-tuples.scala:11:45 --------------------------------------------------------------------------- +11 | type Illformed2 = (name: String, age: Int, name: Boolean) // error | ^^^^^^^^^^^^^ | Duplicate tuple element name --- [E007] Type Mismatch Error: tests/neg/named-tuples.scala:20:20 ------------------------------------------------------ -20 | val _: NameOnly = person // error +-- [E007] Type Mismatch Error: tests/neg/named-tuples.scala:19:20 ------------------------------------------------------ +19 | val _: NameOnly = person // error | ^^^^^^ | Found: (Test.person : (name : String, age : Int)) | Required: Test.NameOnly | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg/named-tuples.scala:21:18 ------------------------------------------------------ -21 | val _: Person = nameOnly // error +-- [E007] Type Mismatch Error: tests/neg/named-tuples.scala:20:18 ------------------------------------------------------ +20 | val _: Person = nameOnly // error | ^^^^^^^^ | Found: (Test.nameOnly : (name : String)) | Required: Test.Person | | longer explanation available when compiling with `-explain` --- [E172] Type Error: tests/neg/named-tuples.scala:22:41 --------------------------------------------------------------- -22 | val _: Person = (name = "") ++ nameOnly // error +-- [E172] Type Error: tests/neg/named-tuples.scala:21:41 --------------------------------------------------------------- +21 | val _: Person = (name = "") ++ nameOnly // error | ^ | Cannot prove that Tuple.Disjoint[Tuple1[("name" : String)], Tuple1[("name" : String)]] =:= (true : Boolean). --- [E008] Not Found Error: tests/neg/named-tuples.scala:23:9 ----------------------------------------------------------- -23 | person._1 // error +-- [E008] Not Found Error: tests/neg/named-tuples.scala:22:9 ----------------------------------------------------------- +22 | person._1 // error | ^^^^^^^^^ | value _1 is not a member of (name : String, age : Int) --- [E007] Type Mismatch Error: tests/neg/named-tuples.scala:25:36 ------------------------------------------------------ -25 | val _: (age: Int, name: String) = person // error +-- [E007] Type Mismatch Error: tests/neg/named-tuples.scala:24:36 ------------------------------------------------------ +24 | val _: (age: Int, name: String) = person // error | ^^^^^^ | Found: (Test.person : (name : String, age : Int)) | Required: (age : Int, name : String) | | longer explanation available when compiling with `-explain` --- Error: tests/neg/named-tuples.scala:27:17 --------------------------------------------------------------------------- -27 | val (name = x, agee = y) = person // error +-- Error: tests/neg/named-tuples.scala:26:17 --------------------------------------------------------------------------- +26 | val (name = x, agee = y) = person // error | ^^^^^^^^ | No element named `agee` is defined in selector type (name : String, age : Int) --- Error: tests/neg/named-tuples.scala:30:10 --------------------------------------------------------------------------- -30 | case (name = n, age = a) => () // error // error +-- Error: tests/neg/named-tuples.scala:29:10 --------------------------------------------------------------------------- +29 | case (name = n, age = a) => () // error // error | ^^^^^^^^ | No element named `name` is defined in selector type (String, Int) --- Error: tests/neg/named-tuples.scala:30:20 --------------------------------------------------------------------------- -30 | case (name = n, age = a) => () // error // error +-- Error: tests/neg/named-tuples.scala:29:20 --------------------------------------------------------------------------- +29 | case (name = n, age = a) => () // error // error | ^^^^^^^ | No element named `age` is defined in selector type (String, Int) --- [E172] Type Error: tests/neg/named-tuples.scala:32:27 --------------------------------------------------------------- -32 | val pp = person ++ (1, 2) // error +-- [E172] Type Error: tests/neg/named-tuples.scala:31:27 --------------------------------------------------------------- +31 | val pp = person ++ (1, 2) // error | ^ | Cannot prove that Tuple.Disjoint[(("name" : String), ("age" : String)), Tuple] =:= (true : Boolean). --- [E172] Type Error: tests/neg/named-tuples.scala:35:18 --------------------------------------------------------------- -35 | person ++ (1, 2) match // error +-- [E172] Type Error: tests/neg/named-tuples.scala:34:18 --------------------------------------------------------------- +34 | person ++ (1, 2) match // error | ^ | Cannot prove that Tuple.Disjoint[(("name" : String), ("age" : String)), Tuple] =:= (true : Boolean). --- Error: tests/neg/named-tuples.scala:38:17 --------------------------------------------------------------------------- -38 | val bad = ("", age = 10) // error +-- Error: tests/neg/named-tuples.scala:37:17 --------------------------------------------------------------------------- +37 | val bad = ("", age = 10) // error | ^^^^^^^^ | Illegal combination of named and unnamed tuple elements --- Error: tests/neg/named-tuples.scala:41:20 --------------------------------------------------------------------------- -41 | case (name = n, age) => () // error +-- Error: tests/neg/named-tuples.scala:40:20 --------------------------------------------------------------------------- +40 | case (name = n, age) => () // error | ^^^ | Illegal combination of named and unnamed tuple elements --- Error: tests/neg/named-tuples.scala:42:16 --------------------------------------------------------------------------- -42 | case (name, age = a) => () // error +-- Error: tests/neg/named-tuples.scala:41:16 --------------------------------------------------------------------------- +41 | case (name, age = a) => () // error | ^^^^^^^ | Illegal combination of named and unnamed tuple elements --- Error: tests/neg/named-tuples.scala:45:10 --------------------------------------------------------------------------- -45 | case (age = x) => // error +-- Error: tests/neg/named-tuples.scala:44:10 --------------------------------------------------------------------------- +44 | case (age = x) => // error | ^^^^^^^ | No element named `age` is defined in selector type Tuple --- [E172] Type Error: tests/neg/named-tuples.scala:47:27 --------------------------------------------------------------- -47 | val p2 = person ++ person // error +-- [E172] Type Error: tests/neg/named-tuples.scala:46:27 --------------------------------------------------------------- +46 | val p2 = person ++ person // error | ^ |Cannot prove that Tuple.Disjoint[(("name" : String), ("age" : String)), (("name" : String), ("age" : String))] =:= (true : Boolean). --- [E172] Type Error: tests/neg/named-tuples.scala:48:43 --------------------------------------------------------------- -48 | val p3 = person ++ (first = 11, age = 33) // error +-- [E172] Type Error: tests/neg/named-tuples.scala:47:43 --------------------------------------------------------------- +47 | val p3 = person ++ (first = 11, age = 33) // error | ^ |Cannot prove that Tuple.Disjoint[(("name" : String), ("age" : String)), (("first" : String), ("age" : String))] =:= (true : Boolean). --- [E007] Type Mismatch Error: tests/neg/named-tuples.scala:50:22 ------------------------------------------------------ -50 | val p5 = person.zip((first = 11, age = 33)) // error +-- [E007] Type Mismatch Error: tests/neg/named-tuples.scala:49:22 ------------------------------------------------------ +49 | val p5 = person.zip((first = 11, age = 33)) // error | ^^^^^^^^^^^^^^^^^^^^^^ | Found: (first : Int, age : Int) | Required: NamedTuple.NamedTuple[(("name" : String), ("age" : String)), Tuple] | | longer explanation available when compiling with `-explain` --- [E007] Type Mismatch Error: tests/neg/named-tuples.scala:61:32 ------------------------------------------------------ -61 | val typo: (name: ?, age: ?) = (name = "he", ag = 1) // error +-- [E007] Type Mismatch Error: tests/neg/named-tuples.scala:60:32 ------------------------------------------------------ +60 | val typo: (name: ?, age: ?) = (name = "he", ag = 1) // error | ^^^^^^^^^^^^^^^^^^^^^ | Found: (name : String, ag : Int) | Required: (name : ?, age : ?) diff --git a/tests/neg/named-tuples.scala b/tests/neg/named-tuples.scala index 8f78f7915206..daae6e26bac2 100644 --- a/tests/neg/named-tuples.scala +++ b/tests/neg/named-tuples.scala @@ -1,7 +1,6 @@ import annotation.experimental -import language.experimental.namedTuples -@experimental object Test: +object Test: type Person = (name: String, age: Int) val person = (name = "Bob", age = 33): (name: String, age: Int) diff --git a/tests/new/test.scala b/tests/new/test.scala index 18644422ab06..dc1891f3525c 100644 --- a/tests/new/test.scala +++ b/tests/new/test.scala @@ -1,5 +1,3 @@ -import language.experimental.namedTuples - type Person = (name: String, age: Int) trait A: diff --git a/tests/pos/fieldsOf.scala b/tests/pos/fieldsOf.scala index 2594dae2cbf7..08f20a1f7e8e 100644 --- a/tests/pos/fieldsOf.scala +++ b/tests/pos/fieldsOf.scala @@ -1,5 +1,3 @@ -import language.experimental.namedTuples - case class Person(name: String, age: Int) type PF = NamedTuple.From[Person] diff --git a/tests/pos/i20377.scala b/tests/pos/i20377.scala index 661fa7adfca9..a555e01867ab 100644 --- a/tests/pos/i20377.scala +++ b/tests/pos/i20377.scala @@ -1,4 +1,3 @@ -import language.experimental.namedTuples import NamedTuple.{NamedTuple, AnyNamedTuple} // Repros for bugs or questions diff --git a/tests/pos/i21300.scala b/tests/pos/i21300.scala index 22859482ef98..e7c7965b0e9a 100644 --- a/tests/pos/i21300.scala +++ b/tests/pos/i21300.scala @@ -1,17 +1,15 @@ -import scala.language.experimental.namedTuples - class Test[S <: String & Singleton](name: S): type NT = NamedTuple.NamedTuple[(S, "foo"), (Int, Long)] def nt: NT = ??? type Name = S - + type NT2 = NamedTuple.NamedTuple[(Name, "foo"), (Int, Long)] def nt2: NT2 = ??? def test = val foo = new Test("bar") - + foo.nt.bar foo.nt2.bar diff --git a/tests/pos/i21413.scala b/tests/pos/i21413.scala index 72b5c6d59d8d..d2dc52e34630 100644 --- a/tests/pos/i21413.scala +++ b/tests/pos/i21413.scala @@ -1,4 +1,2 @@ -import scala.language.experimental.namedTuples - val x = (aaa = 1).aaa //val y = x.aaa \ No newline at end of file diff --git a/tests/pos/i22018.scala b/tests/pos/i22018.scala index 14f4733732be..05e5c8279144 100644 --- a/tests/pos/i22018.scala +++ b/tests/pos/i22018.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - class SelectableNT[A <: NamedTuple.AnyNamedTuple](val nt: A) extends Selectable: type Fields = A def selectDynamic(x: String) = ??? diff --git a/tests/pos/i22036.scala b/tests/pos/i22036.scala index 99a1502a253f..065970e4db9b 100644 --- a/tests/pos/i22036.scala +++ b/tests/pos/i22036.scala @@ -1,6 +1,3 @@ -//> using options -experimental -language:experimental.namedTuples -import language.experimental.namedTuples - type Foo[T] = T val x: NamedTuple.From[Tuple.Map[(Int, Int), Foo]] = ??? val res = x._1 diff --git a/tests/pos/i22192.scala b/tests/pos/i22192.scala index 4214a56f4b38..e97b04fb5763 100644 --- a/tests/pos/i22192.scala +++ b/tests/pos/i22192.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - case class City(name: String, population: Int) def getCityInfo(city: City) = city match diff --git a/tests/pos/i22324.scala b/tests/pos/i22324.scala index b35f82d52ac9..96ea1d54afc5 100644 --- a/tests/pos/i22324.scala +++ b/tests/pos/i22324.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - opaque type System = (wires: Any) extension (system: System) diff --git a/tests/pos/named-tuple-combinators.scala b/tests/pos/named-tuple-combinators.scala index a5134b2e7d26..c027ba688d02 100644 --- a/tests/pos/named-tuple-combinators.scala +++ b/tests/pos/named-tuple-combinators.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.namedTuples object Test: // original code from issue https://github.com/scala/scala3/issues/20427 diff --git a/tests/pos/named-tuple-downcast.scala b/tests/pos/named-tuple-downcast.scala index b9876623faf2..239089b60c3d 100644 --- a/tests/pos/named-tuple-downcast.scala +++ b/tests/pos/named-tuple-downcast.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - type Person = (name: String, age: Int) val Bob: Person = (name = "Bob", age = 33) diff --git a/tests/pos/named-tuple-selectable.scala b/tests/pos/named-tuple-selectable.scala index be5f0400e58c..0e1324f70ae6 100644 --- a/tests/pos/named-tuple-selectable.scala +++ b/tests/pos/named-tuple-selectable.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.namedTuples class FromFields extends Selectable: type Fields = (xs: List[Int], poly: [T] => (x: List[T]) => Option[T]) diff --git a/tests/pos/named-tuple-selections.scala b/tests/pos/named-tuple-selections.scala index c3569f21b323..7b73daad2e72 100644 --- a/tests/pos/named-tuple-selections.scala +++ b/tests/pos/named-tuple-selections.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.namedTuples object Test1: // original code from issue https://github.com/scala/scala3/issues/20439 diff --git a/tests/pos/named-tuple-unstable.scala b/tests/pos/named-tuple-unstable.scala index 6a6a36732a14..d15bdc578a3a 100644 --- a/tests/pos/named-tuple-unstable.scala +++ b/tests/pos/named-tuple-unstable.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.namedTuples import NamedTuple.{AnyNamedTuple, NamedTuple} trait Foo extends Selectable: diff --git a/tests/pos/named-tuple-widen.scala b/tests/pos/named-tuple-widen.scala index 410832e04c17..cc12a5f09b16 100644 --- a/tests/pos/named-tuple-widen.scala +++ b/tests/pos/named-tuple-widen.scala @@ -1,4 +1,3 @@ -import language.experimental.namedTuples class A class B diff --git a/tests/pos/named-tuples-ops-mirror.scala b/tests/pos/named-tuples-ops-mirror.scala index f66eb89534fb..b8745cf785d5 100644 --- a/tests/pos/named-tuples-ops-mirror.scala +++ b/tests/pos/named-tuples-ops-mirror.scala @@ -1,4 +1,3 @@ -import language.experimental.namedTuples import NamedTuple.* @FailsWith[HttpError] diff --git a/tests/pos/named-tuples1.scala b/tests/pos/named-tuples1.scala index 58e3fc065e61..532f1df7efd4 100644 --- a/tests/pos/named-tuples1.scala +++ b/tests/pos/named-tuples1.scala @@ -1,5 +1,4 @@ import annotation.experimental -import language.experimental.namedTuples @main def Test = val bob = (name = "Bob", age = 33): (name: String, age: Int) diff --git a/tests/pos/namedtuple-src-incompat.scala b/tests/pos/namedtuple-src-incompat.scala index 57451a4321b7..76eb5e4aa850 100644 --- a/tests/pos/namedtuple-src-incompat.scala +++ b/tests/pos/namedtuple-src-incompat.scala @@ -1,4 +1,3 @@ -import language.experimental.namedTuples var age = 22 val x = (age = 1) val _: (age: Int) = x diff --git a/tests/pos/tuple-ops.scala b/tests/pos/tuple-ops.scala index 739b1ebeeb02..e89c0e8e51aa 100644 --- a/tests/pos/tuple-ops.scala +++ b/tests/pos/tuple-ops.scala @@ -1,4 +1,3 @@ -import language.experimental.namedTuples import Tuple.* def test = diff --git a/tests/rewrites/ambiguous-named-tuple-assignment.check b/tests/rewrites/ambiguous-named-tuple-assignment.check index 00e6cc4112f1..2f2dd7721239 100644 --- a/tests/rewrites/ambiguous-named-tuple-assignment.check +++ b/tests/rewrites/ambiguous-named-tuple-assignment.check @@ -1,17 +1,15 @@ -import scala.language.experimental.namedTuples - object i21770: def f(g: Int => Unit) = g(0) var cache: Option[Int] = None f(i => {cache = Some(i)}) - + object i21861: var age: Int = 28 { age = 29 } - - + + object i21861c: def age: Int = ??? def age_=(x: Int): Unit = () diff --git a/tests/rewrites/ambiguous-named-tuple-assignment.scala b/tests/rewrites/ambiguous-named-tuple-assignment.scala index e9685b7b58cf..189c804fbe01 100644 --- a/tests/rewrites/ambiguous-named-tuple-assignment.scala +++ b/tests/rewrites/ambiguous-named-tuple-assignment.scala @@ -1,17 +1,15 @@ -import scala.language.experimental.namedTuples - object i21770: def f(g: Int => Unit) = g(0) var cache: Option[Int] = None f(i => (cache = Some(i))) - + object i21861: var age: Int = 28 ( age = 29 ) - - + + object i21861c: def age: Int = ??? def age_=(x: Int): Unit = () diff --git a/tests/rewrites/infix-named-args.check b/tests/rewrites/infix-named-args.check index 5f59cf272ba1..7f85ab490ca4 100644 --- a/tests/rewrites/infix-named-args.check +++ b/tests/rewrites/infix-named-args.check @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - class C: def multi(x: Int, y: Int): Int = x + y def **(x: Int, y: Int): Int = x + y diff --git a/tests/rewrites/infix-named-args.scala b/tests/rewrites/infix-named-args.scala index a954776a9104..bcdf4a21a9d2 100644 --- a/tests/rewrites/infix-named-args.scala +++ b/tests/rewrites/infix-named-args.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - class C: def multi(x: Int, y: Int): Int = x + y def **(x: Int, y: Int): Int = x + y diff --git a/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala b/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala index bda454c0be2b..0715bedea201 100644 --- a/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala +++ b/tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala @@ -78,12 +78,6 @@ val experimentalDefinitionInLibrary = Set( // New feature: fromNullable for explicit nulls "scala.Predef$.fromNullable", - // New feature: named tuples - "scala.NamedTuple", - "scala.NamedTuple$", - "scala.NamedTupleDecomposition", - "scala.NamedTupleDecomposition$", - // New feature: modularity "scala.Precise", "scala.annotation.internal.WitnessNames", diff --git a/tests/run/i22150.scala b/tests/run/i22150.scala index 80c2222a98e7..0a4be2047cd8 100644 --- a/tests/run/i22150.scala +++ b/tests/run/i22150.scala @@ -1,6 +1,3 @@ -//> using options -experimental -language:experimental.namedTuples -import language.experimental.namedTuples - val directionsNT = IArray( (dx = 0, dy = 1), // up (dx = 1, dy = 0), // right diff --git a/tests/run/named-patmatch.scala b/tests/run/named-patmatch.scala index e62497e4aa8f..6fe1934f008e 100644 --- a/tests/run/named-patmatch.scala +++ b/tests/run/named-patmatch.scala @@ -1,5 +1,4 @@ import annotation.experimental -import language.experimental.namedTuples @main def Test = locally: diff --git a/tests/run/named-patterns.scala b/tests/run/named-patterns.scala index 7c24dc8d683a..e92bbf751c22 100644 --- a/tests/run/named-patterns.scala +++ b/tests/run/named-patterns.scala @@ -1,4 +1,3 @@ -import language.experimental.namedTuples object Test1: class Person(val name: String, val age: Int) diff --git a/tests/run/named-tuple-ops.scala b/tests/run/named-tuple-ops.scala index 076ab5028c6c..8c6db6f2fa1c 100644 --- a/tests/run/named-tuple-ops.scala +++ b/tests/run/named-tuple-ops.scala @@ -1,5 +1,4 @@ //> using options -source future -import language.experimental.namedTuples import scala.compiletime.asMatchable type City = (name: String, zip: Int, pop: Int) diff --git a/tests/run/named-tuples-mirror.scala b/tests/run/named-tuples-mirror.scala index 5dfdb6ef3104..02706e942225 100644 --- a/tests/run/named-tuples-mirror.scala +++ b/tests/run/named-tuples-mirror.scala @@ -1,4 +1,3 @@ -import scala.language.experimental.namedTuples import scala.deriving.* import scala.compiletime.* diff --git a/tests/run/named-tuples-xxl.scala b/tests/run/named-tuples-xxl.scala index 3a0a1e5e1294..8c831fb1d223 100644 --- a/tests/run/named-tuples-xxl.scala +++ b/tests/run/named-tuples-xxl.scala @@ -1,4 +1,3 @@ -import language.experimental.namedTuples import NamedTuple.toTuple type Person = ( diff --git a/tests/run/named-tuples.scala b/tests/run/named-tuples.scala index 406c6195cf0f..c99393a403b3 100644 --- a/tests/run/named-tuples.scala +++ b/tests/run/named-tuples.scala @@ -1,4 +1,3 @@ -import language.experimental.namedTuples import NamedTuple.* type Person = (name: String, age: Int) diff --git a/tests/run/tyql.scala b/tests/run/tyql.scala index 8fe253b559ac..ee3fd1138265 100644 --- a/tests/run/tyql.scala +++ b/tests/run/tyql.scala @@ -1,4 +1,3 @@ -import language.experimental.namedTuples import NamedTuple.{NamedTuple, AnyNamedTuple} /* This is a demonstrator that shows how to map regular for expressions to diff --git a/tests/warn/21681.check b/tests/warn/21681.check index adf3586e6e0b..70c8e6e2170c 100644 --- a/tests/warn/21681.check +++ b/tests/warn/21681.check @@ -1,7 +1,7 @@ --- [E203] Syntax Migration Warning: tests/warn/21681.scala:5:2 --------------------------------------------------------- -5 | (age = 29) // warn +-- [E203] Syntax Migration Warning: tests/warn/21681.scala:3:2 --------------------------------------------------------- +3 | (age = 29) // warn | ^^^^^^^^^^ - | Deprecated syntax: in the future it would be interpreted as a named tuple with one element, + | Deprecated syntax: since 3.7 this is interpreted as a named tuple with one element, | not as an assignment. | | To assign a value, use curly braces: `{age = 29}`. diff --git a/tests/warn/21681.scala b/tests/warn/21681.scala index 67f45571ecf6..76a19c96e1cb 100644 --- a/tests/warn/21681.scala +++ b/tests/warn/21681.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - def main() = var age: Int = 28 (age = 29) // warn diff --git a/tests/warn/21681b.check b/tests/warn/21681b.check index 09c007f351b4..b00dcae7cf04 100644 --- a/tests/warn/21681b.check +++ b/tests/warn/21681b.check @@ -1,7 +1,7 @@ --- [E203] Syntax Migration Warning: tests/warn/21681b.scala:5:2 -------------------------------------------------------- -5 | (age = 29) // warn +-- [E203] Syntax Migration Warning: tests/warn/21681b.scala:3:2 -------------------------------------------------------- +3 | (age = 29) // warn | ^^^^^^^^^^ - | Deprecated syntax: in the future it would be interpreted as a named tuple with one element, + | Deprecated syntax: since 3.7 this is interpreted as a named tuple with one element, | not as an assignment. | | To assign a value, use curly braces: `{age = 29}`. diff --git a/tests/warn/21681b.scala b/tests/warn/21681b.scala index 44d04fc98aad..710d69b0dd23 100644 --- a/tests/warn/21681b.scala +++ b/tests/warn/21681b.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - object Test: var age: Int = 28 (age = 29) // warn diff --git a/tests/warn/21681c.check b/tests/warn/21681c.check index 20273f723384..1c42cc17243a 100644 --- a/tests/warn/21681c.check +++ b/tests/warn/21681c.check @@ -1,7 +1,7 @@ --- [E203] Syntax Migration Warning: tests/warn/21681c.scala:7:2 -------------------------------------------------------- -7 | (age = 29) // warn +-- [E203] Syntax Migration Warning: tests/warn/21681c.scala:5:2 -------------------------------------------------------- +5 | (age = 29) // warn | ^^^^^^^^^^ - | Deprecated syntax: in the future it would be interpreted as a named tuple with one element, + | Deprecated syntax: since 3.7 this is interpreted as a named tuple with one element, | not as an assignment. | | To assign a value, use curly braces: `{age = 29}`. diff --git a/tests/warn/21681c.scala b/tests/warn/21681c.scala index a0c361382a54..5e2eae11708c 100644 --- a/tests/warn/21681c.scala +++ b/tests/warn/21681c.scala @@ -1,5 +1,3 @@ -import scala.language.experimental.namedTuples - object Test: def age: Int = ??? def age_=(x: Int): Unit = () diff --git a/tests/warn/21770.check b/tests/warn/21770.check index 7853d77a423c..65d3cdcbbfff 100644 --- a/tests/warn/21770.check +++ b/tests/warn/21770.check @@ -1,7 +1,7 @@ --- [E203] Syntax Migration Warning: tests/warn/21770.scala:7:9 --------------------------------------------------------- -7 | f(i => (cache = Some(i))) // warn +-- [E203] Syntax Migration Warning: tests/warn/21770.scala:5:9 --------------------------------------------------------- +5 | f(i => (cache = Some(i))) // warn | ^^^^^^^^^^^^^^^^^ - | Deprecated syntax: in the future it would be interpreted as a named tuple with one element, + | Deprecated syntax: since 3.7 this is interpreted as a named tuple with one element, | not as an assignment. | | To assign a value, use curly braces: `{cache = Some(i)}`. diff --git a/tests/warn/21770.scala b/tests/warn/21770.scala index 8ee5b52e7b3f..9696a31d6ba8 100644 --- a/tests/warn/21770.scala +++ b/tests/warn/21770.scala @@ -1,7 +1,5 @@ -import scala.language.experimental.namedTuples - def f(g: Int => Unit) = g(0) -def test = +def test = var cache: Option[Int] = None f(i => (cache = Some(i))) // warn diff --git a/tests/warn/infix-named-args-migration.scala b/tests/warn/infix-named-args-migration.scala index 361004f08f13..c6da1923ee94 100644 --- a/tests/warn/infix-named-args-migration.scala +++ b/tests/warn/infix-named-args-migration.scala @@ -1,5 +1,4 @@ -//> using options -source:3.6-migration -import scala.language.experimental.namedTuples +//> using options -source:3.7-migration class C: def f = 42 + (x = 1) // warn // interpreted as 42.+(x = 1) under migration, x is a valid synthetic parameter name