Skip to content

Commit 1162b32

Browse files
Update private[this] deprecation warning and documentation (#19393)
Fixes #19339
2 parents fa93c73 + 18795e4 commit 1162b32

File tree

6 files changed

+35
-18
lines changed

6 files changed

+35
-18
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -3151,7 +3151,8 @@ object Parsers {
31513151
}
31523152
if mods1.is(Local) then
31533153
report.errorOrMigrationWarning(
3154-
em"""The [this] qualifier will be deprecated in the future; it should be dropped.
3154+
em"""Ignoring [this] qualifier.
3155+
|This syntax will be deprecated in the future; it should be dropped.
31553156
|See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html${rewriteNotice(`3.4-migration`)}""",
31563157
in.sourcePos(),
31573158
MigrationVersion.RemoveThisQualifier)

docs/_spec/APPLIEDreference/dropped-features/this-qualifier.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "Dropped: private[this] and protected[this]"
44
nightlyOf: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
55
---
66

7-
The `private[this]` and `protected[this]` access modifiers will be deprecated and phased out.
7+
The `private[this]` and `protected[this]` access modifiers will be deprecated and phased out. Migration warning will be shown in Scala 3.4+.
88

99
Previously, these modifiers were needed for
1010

tests/neg-scalajs/js-native-members.check

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
-- Warning: tests/neg-scalajs/js-native-members.scala:24:16 ------------------------------------------------------------
22
24 | private[this] def this(x: Int) = this() // ok
33
| ^
4-
| The [this] qualifier will be deprecated in the future; it should be dropped.
4+
| Ignoring [this] qualifier.
5+
| This syntax will be deprecated in the future; it should be dropped.
56
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
67
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
78
-- Warning: tests/neg-scalajs/js-native-members.scala:28:16 ------------------------------------------------------------
89
28 | private[this] val a: Int = js.native // error
910
| ^
10-
| The [this] qualifier will be deprecated in the future; it should be dropped.
11+
| Ignoring [this] qualifier.
12+
| This syntax will be deprecated in the future; it should be dropped.
1113
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
1214
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
1315
-- Warning: tests/neg-scalajs/js-native-members.scala:32:16 ------------------------------------------------------------
1416
32 | private[this] var d: Int = js.native // error
1517
| ^
16-
| The [this] qualifier will be deprecated in the future; it should be dropped.
18+
| Ignoring [this] qualifier.
19+
| This syntax will be deprecated in the future; it should be dropped.
1720
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
1821
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
1922
-- Warning: tests/neg-scalajs/js-native-members.scala:36:16 ------------------------------------------------------------
2023
36 | private[this] def g(): Int = js.native // error
2124
| ^
22-
| The [this] qualifier will be deprecated in the future; it should be dropped.
25+
| Ignoring [this] qualifier.
26+
| This syntax will be deprecated in the future; it should be dropped.
2327
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
2428
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
2529
-- Warning: tests/neg-scalajs/js-native-members.scala:49:25 ------------------------------------------------------------
2630
49 | class X3 private[this] () extends js.Object { // ok
2731
| ^
28-
| The [this] qualifier will be deprecated in the future; it should be dropped.
32+
| Ignoring [this] qualifier.
33+
| This syntax will be deprecated in the future; it should be dropped.
2934
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
3035
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
3136
-- [E003] Syntax Warning: tests/neg-scalajs/js-native-members.scala:58:44 ----------------------------------------------

tests/neg-scalajs/js-non-native-members-qualified-private.check

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
-- Warning: tests/neg-scalajs/js-non-native-members-qualified-private.scala:52:28 --------------------------------------
22
52 | class B private[this] () extends js.Object // ok
33
| ^
4-
| The [this] qualifier will be deprecated in the future; it should be dropped.
4+
| Ignoring [this] qualifier.
5+
| This syntax will be deprecated in the future; it should be dropped.
56
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
67
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
78
-- Error: tests/neg-scalajs/js-non-native-members-qualified-private.scala:6:32 -----------------------------------------

tests/neg/private-this-3.4.check

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
-- Error: tests/neg/private-this-3.4.scala:6:16 ------------------------------------------------------------------------
22
6 | private[this] def foo: Int = ??? // error: migration warning
33
| ^
4-
| The [this] qualifier will be deprecated in the future; it should be dropped.
4+
| Ignoring [this] qualifier.
5+
| This syntax will be deprecated in the future; it should be dropped.
56
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
67
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
78
-- Error: tests/neg/private-this-3.4.scala:7:18 ------------------------------------------------------------------------
89
7 | protected[this] def bar: Int = ??? // error: migration warning
910
| ^
10-
| The [this] qualifier will be deprecated in the future; it should be dropped.
11+
| Ignoring [this] qualifier.
12+
| This syntax will be deprecated in the future; it should be dropped.
1113
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
1214
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.

tests/semanticdb/metac.expect

+16-8
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ Occurrences:
4444

4545
Diagnostics:
4646
[3:14..3:16): [warning] unused private member
47-
[4:16..4:16): [warning] The [this] qualifier will be deprecated in the future; it should be dropped.
47+
[4:16..4:16): [warning] Ignoring [this] qualifier.
48+
This syntax will be deprecated in the future; it should be dropped.
4849
See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
4950
This construct can be rewritten automatically under -rewrite -source 3.4-migration.
5051
[4:20..4:22): [warning] unused private member
51-
[7:18..7:18): [warning] The [this] qualifier will be deprecated in the future; it should be dropped.
52+
[7:18..7:18): [warning] Ignoring [this] qualifier.
53+
This syntax will be deprecated in the future; it should be dropped.
5254
See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
5355
This construct can be rewritten automatically under -rewrite -source 3.4-migration.
5456

@@ -817,11 +819,13 @@ Occurrences:
817819

818820
Diagnostics:
819821
[18:9..18:10): [warning] unused explicit parameter
820-
[20:23..20:23): [warning] The [this] qualifier will be deprecated in the future; it should be dropped.
822+
[20:23..20:23): [warning] Ignoring [this] qualifier.
823+
This syntax will be deprecated in the future; it should be dropped.
821824
See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
822825
This construct can be rewritten automatically under -rewrite -source 3.4-migration.
823826
[20:27..20:28): [warning] unused explicit parameter
824-
[22:23..22:23): [warning] The [this] qualifier will be deprecated in the future; it should be dropped.
827+
[22:23..22:23): [warning] Ignoring [this] qualifier.
828+
This syntax will be deprecated in the future; it should be dropped.
825829
See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
826830
This construct can be rewritten automatically under -rewrite -source 3.4-migration.
827831
[22:27..22:28): [warning] unused explicit parameter
@@ -4129,16 +4133,20 @@ Occurrences:
41294133

41304134
Diagnostics:
41314135
[2:20..2:21): [warning] unused explicit parameter
4132-
[5:16..5:16): [warning] The [this] qualifier will be deprecated in the future; it should be dropped.
4136+
[5:16..5:16): [warning] Ignoring [this] qualifier.
4137+
This syntax will be deprecated in the future; it should be dropped.
41334138
See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
41344139
This construct can be rewritten automatically under -rewrite -source 3.4-migration.
4135-
[7:16..7:16): [warning] The [this] qualifier will be deprecated in the future; it should be dropped.
4140+
[7:16..7:16): [warning] Ignoring [this] qualifier.
4141+
This syntax will be deprecated in the future; it should be dropped.
41364142
See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
41374143
This construct can be rewritten automatically under -rewrite -source 3.4-migration.
4138-
[12:16..12:16): [warning] The [this] qualifier will be deprecated in the future; it should be dropped.
4144+
[12:16..12:16): [warning] Ignoring [this] qualifier.
4145+
This syntax will be deprecated in the future; it should be dropped.
41394146
See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
41404147
This construct can be rewritten automatically under -rewrite -source 3.4-migration.
4141-
[13:16..13:16): [warning] The [this] qualifier will be deprecated in the future; it should be dropped.
4148+
[13:16..13:16): [warning] Ignoring [this] qualifier.
4149+
This syntax will be deprecated in the future; it should be dropped.
41424150
See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
41434151
This construct can be rewritten automatically under -rewrite -source 3.4-migration.
41444152

0 commit comments

Comments
 (0)