From 18795e4117d6e50121b5c139dbd6cba74e137e02 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 8 Jan 2024 09:11:19 +0100 Subject: [PATCH] Update `private[this]` deprecation warning and documentation --- .../dotty/tools/dotc/parsing/Parsers.scala | 3 ++- .../dropped-features/this-qualifier.md | 2 +- tests/neg-scalajs/js-native-members.check | 15 ++++++++---- ...non-native-members-qualified-private.check | 3 ++- tests/neg/private-this-3.4.check | 6 +++-- tests/semanticdb/metac.expect | 24 ++++++++++++------- 6 files changed, 35 insertions(+), 18 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 47b7ffbbc840..5467f2e1247f 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3151,7 +3151,8 @@ object Parsers { } if mods1.is(Local) then report.errorOrMigrationWarning( - em"""The [this] qualifier will be deprecated in the future; it should be dropped. + em"""Ignoring [this] qualifier. + |This syntax will be deprecated in the future; it should be dropped. |See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html${rewriteNotice(`3.4-migration`)}""", in.sourcePos(), MigrationVersion.RemoveThisQualifier) diff --git a/docs/_spec/APPLIEDreference/dropped-features/this-qualifier.md b/docs/_spec/APPLIEDreference/dropped-features/this-qualifier.md index 3fcaefb7e0d8..9eb0a77e2b69 100644 --- a/docs/_spec/APPLIEDreference/dropped-features/this-qualifier.md +++ b/docs/_spec/APPLIEDreference/dropped-features/this-qualifier.md @@ -4,7 +4,7 @@ title: "Dropped: private[this] and protected[this]" nightlyOf: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html --- -The `private[this]` and `protected[this]` access modifiers will be deprecated and phased out. +The `private[this]` and `protected[this]` access modifiers will be deprecated and phased out. Migration warning will be shown in Scala 3.4+. Previously, these modifiers were needed for diff --git a/tests/neg-scalajs/js-native-members.check b/tests/neg-scalajs/js-native-members.check index 11acee62af90..60990cbf3d97 100644 --- a/tests/neg-scalajs/js-native-members.check +++ b/tests/neg-scalajs/js-native-members.check @@ -1,31 +1,36 @@ -- Warning: tests/neg-scalajs/js-native-members.scala:24:16 ------------------------------------------------------------ 24 | private[this] def this(x: Int) = this() // ok | ^ - | The [this] qualifier will be deprecated in the future; it should be dropped. + | Ignoring [this] qualifier. + | This syntax will be deprecated in the future; it should be dropped. | See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html | This construct can be rewritten automatically under -rewrite -source 3.4-migration. -- Warning: tests/neg-scalajs/js-native-members.scala:28:16 ------------------------------------------------------------ 28 | private[this] val a: Int = js.native // error | ^ - | The [this] qualifier will be deprecated in the future; it should be dropped. + | Ignoring [this] qualifier. + | This syntax will be deprecated in the future; it should be dropped. | See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html | This construct can be rewritten automatically under -rewrite -source 3.4-migration. -- Warning: tests/neg-scalajs/js-native-members.scala:32:16 ------------------------------------------------------------ 32 | private[this] var d: Int = js.native // error | ^ - | The [this] qualifier will be deprecated in the future; it should be dropped. + | Ignoring [this] qualifier. + | This syntax will be deprecated in the future; it should be dropped. | See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html | This construct can be rewritten automatically under -rewrite -source 3.4-migration. -- Warning: tests/neg-scalajs/js-native-members.scala:36:16 ------------------------------------------------------------ 36 | private[this] def g(): Int = js.native // error | ^ - | The [this] qualifier will be deprecated in the future; it should be dropped. + | Ignoring [this] qualifier. + | This syntax will be deprecated in the future; it should be dropped. | See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html | This construct can be rewritten automatically under -rewrite -source 3.4-migration. -- Warning: tests/neg-scalajs/js-native-members.scala:49:25 ------------------------------------------------------------ 49 | class X3 private[this] () extends js.Object { // ok | ^ - | The [this] qualifier will be deprecated in the future; it should be dropped. + | Ignoring [this] qualifier. + | This syntax will be deprecated in the future; it should be dropped. | See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html | This construct can be rewritten automatically under -rewrite -source 3.4-migration. -- [E003] Syntax Warning: tests/neg-scalajs/js-native-members.scala:58:44 ---------------------------------------------- diff --git a/tests/neg-scalajs/js-non-native-members-qualified-private.check b/tests/neg-scalajs/js-non-native-members-qualified-private.check index fb06b91f98f8..6befabb7a9c0 100644 --- a/tests/neg-scalajs/js-non-native-members-qualified-private.check +++ b/tests/neg-scalajs/js-non-native-members-qualified-private.check @@ -1,7 +1,8 @@ -- Warning: tests/neg-scalajs/js-non-native-members-qualified-private.scala:52:28 -------------------------------------- 52 | class B private[this] () extends js.Object // ok | ^ - | The [this] qualifier will be deprecated in the future; it should be dropped. + | Ignoring [this] qualifier. + | This syntax will be deprecated in the future; it should be dropped. | See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html | This construct can be rewritten automatically under -rewrite -source 3.4-migration. -- Error: tests/neg-scalajs/js-non-native-members-qualified-private.scala:6:32 ----------------------------------------- diff --git a/tests/neg/private-this-3.4.check b/tests/neg/private-this-3.4.check index 29c2fe909ede..8ee55d2b5f29 100644 --- a/tests/neg/private-this-3.4.check +++ b/tests/neg/private-this-3.4.check @@ -1,12 +1,14 @@ -- Error: tests/neg/private-this-3.4.scala:6:16 ------------------------------------------------------------------------ 6 | private[this] def foo: Int = ??? // error: migration warning | ^ - | The [this] qualifier will be deprecated in the future; it should be dropped. + | Ignoring [this] qualifier. + | This syntax will be deprecated in the future; it should be dropped. | See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html | This construct can be rewritten automatically under -rewrite -source 3.4-migration. -- Error: tests/neg/private-this-3.4.scala:7:18 ------------------------------------------------------------------------ 7 | protected[this] def bar: Int = ??? // error: migration warning | ^ - | The [this] qualifier will be deprecated in the future; it should be dropped. + | Ignoring [this] qualifier. + | This syntax will be deprecated in the future; it should be dropped. | See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html | This construct can be rewritten automatically under -rewrite -source 3.4-migration. diff --git a/tests/semanticdb/metac.expect b/tests/semanticdb/metac.expect index c8b652d85469..5c35edf734a9 100644 --- a/tests/semanticdb/metac.expect +++ b/tests/semanticdb/metac.expect @@ -44,11 +44,13 @@ Occurrences: Diagnostics: [3:14..3:16): [warning] unused private member -[4:16..4:16): [warning] The [this] qualifier will be deprecated in the future; it should be dropped. +[4:16..4:16): [warning] Ignoring [this] qualifier. +This syntax will be deprecated in the future; it should be dropped. See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html This construct can be rewritten automatically under -rewrite -source 3.4-migration. [4:20..4:22): [warning] unused private member -[7:18..7:18): [warning] The [this] qualifier will be deprecated in the future; it should be dropped. +[7:18..7:18): [warning] Ignoring [this] qualifier. +This syntax will be deprecated in the future; it should be dropped. See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html This construct can be rewritten automatically under -rewrite -source 3.4-migration. @@ -817,11 +819,13 @@ Occurrences: Diagnostics: [18:9..18:10): [warning] unused explicit parameter -[20:23..20:23): [warning] The [this] qualifier will be deprecated in the future; it should be dropped. +[20:23..20:23): [warning] Ignoring [this] qualifier. +This syntax will be deprecated in the future; it should be dropped. See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html This construct can be rewritten automatically under -rewrite -source 3.4-migration. [20:27..20:28): [warning] unused explicit parameter -[22:23..22:23): [warning] The [this] qualifier will be deprecated in the future; it should be dropped. +[22:23..22:23): [warning] Ignoring [this] qualifier. +This syntax will be deprecated in the future; it should be dropped. See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html This construct can be rewritten automatically under -rewrite -source 3.4-migration. [22:27..22:28): [warning] unused explicit parameter @@ -4129,16 +4133,20 @@ Occurrences: Diagnostics: [2:20..2:21): [warning] unused explicit parameter -[5:16..5:16): [warning] The [this] qualifier will be deprecated in the future; it should be dropped. +[5:16..5:16): [warning] Ignoring [this] qualifier. +This syntax will be deprecated in the future; it should be dropped. See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html This construct can be rewritten automatically under -rewrite -source 3.4-migration. -[7:16..7:16): [warning] The [this] qualifier will be deprecated in the future; it should be dropped. +[7:16..7:16): [warning] Ignoring [this] qualifier. +This syntax will be deprecated in the future; it should be dropped. See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html This construct can be rewritten automatically under -rewrite -source 3.4-migration. -[12:16..12:16): [warning] The [this] qualifier will be deprecated in the future; it should be dropped. +[12:16..12:16): [warning] Ignoring [this] qualifier. +This syntax will be deprecated in the future; it should be dropped. See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html This construct can be rewritten automatically under -rewrite -source 3.4-migration. -[13:16..13:16): [warning] The [this] qualifier will be deprecated in the future; it should be dropped. +[13:16..13:16): [warning] Ignoring [this] qualifier. +This syntax will be deprecated in the future; it should be dropped. See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html This construct can be rewritten automatically under -rewrite -source 3.4-migration.