Skip to content

Commit 2da56bc

Browse files
committed
Improve this qualifier warning
1 parent 5dd17c7 commit 2da56bc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3426,9 +3426,10 @@ object Parsers {
34263426
}
34273427
if mods1.is(Local) then
34283428
val span = Span(startOffset, in.lastOffset)
3429+
val p = if mods1.is(Private) then "private" else "protected"
34293430
report.errorOrMigrationWarning(
34303431
em"""Ignoring [this] qualifier.
3431-
|This syntax will be deprecated in the future; it should be dropped.
3432+
|The syntax `$p[this]` will be deprecated in the future; just write `$p` instead.
34323433
|See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html${rewriteNotice(`3.4-migration`)}""",
34333434
in.sourcePos().withSpan(span),
34343435
MigrationVersion.RemoveThisQualifier)

tests/warn/private-this-3.4.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
4 | private[this] def foo: Int = ??? // warn: migration warning
33
| ^^^^^^
44
| Ignoring [this] qualifier.
5-
| This syntax will be deprecated in the future; it should be dropped.
5+
| The syntax `private[this]` will be deprecated in the future; just write `private` instead.
66
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
77
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
88
-- Warning: tests/warn/private-this-3.4.scala:5:11 ---------------------------------------------------------------------
99
5 | protected[this] def bar: Int = ??? // warn: migration warning
1010
| ^^^^^^
1111
| Ignoring [this] qualifier.
12-
| This syntax will be deprecated in the future; it should be dropped.
12+
| The syntax `protected[this]` will be deprecated in the future; just write `protected` instead.
1313
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
1414
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.

0 commit comments

Comments
 (0)