Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update private[this] deprecation warning and documentation #19393

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading