Skip to content

Commit

Permalink
Update private[this] deprecation warning and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Jan 8, 2024
1 parent c15cc9c commit 18795e4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 10 additions & 5 deletions tests/neg-scalajs/js-native-members.check
Original file line number Diff line number Diff line change
@@ -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 ----------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -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 -----------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions tests/neg/private-this-3.4.check
Original file line number Diff line number Diff line change
@@ -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.
24 changes: 16 additions & 8 deletions tests/semanticdb/metac.expect
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit 18795e4

Please sign in to comment.