Skip to content

Commit 1c312cf

Browse files
committed
Fix span of private this warning
1 parent 5109a15 commit 1c312cf

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,14 +3425,15 @@ object Parsers {
34253425
else mods.withPrivateWithin(ident().toTypeName)
34263426
}
34273427
if mods1.is(Local) then
3428+
val span = Span(startOffset, in.lastOffset)
34283429
report.errorOrMigrationWarning(
34293430
em"""Ignoring [this] qualifier.
34303431
|This syntax will be deprecated in the future; it should be dropped.
34313432
|See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html${rewriteNotice(`3.4-migration`)}""",
3432-
in.sourcePos(),
3433+
in.sourcePos().withSpan(span),
34333434
MigrationVersion.RemoveThisQualifier)
34343435
if MigrationVersion.RemoveThisQualifier.needsPatch then
3435-
patch(source, Span(startOffset, in.lastOffset), "")
3436+
patch(source, span, "")
34363437
mods1
34373438
}
34383439
else mods

tests/warn/private-this-3.4.check

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
-- Warning: tests/warn/private-this-3.4.scala:4:16 ---------------------------------------------------------------------
1+
-- Warning: tests/warn/private-this-3.4.scala:4:9 ----------------------------------------------------------------------
22
4 | private[this] def foo: Int = ??? // warn: migration warning
3-
| ^
4-
| Ignoring [this] qualifier.
5-
| This syntax will be deprecated in the future; it should be dropped.
6-
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
7-
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
8-
-- Warning: tests/warn/private-this-3.4.scala:5:18 ---------------------------------------------------------------------
3+
| ^^^^^^
4+
| Ignoring [this] qualifier.
5+
| This syntax will be deprecated in the future; it should be dropped.
6+
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
7+
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
8+
-- Warning: tests/warn/private-this-3.4.scala:5:11 ---------------------------------------------------------------------
99
5 | protected[this] def bar: Int = ??? // warn: migration warning
10-
| ^
11-
| Ignoring [this] qualifier.
12-
| This syntax will be deprecated in the future; it should be dropped.
13-
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
14-
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.
10+
| ^^^^^^
11+
| Ignoring [this] qualifier.
12+
| This syntax will be deprecated in the future; it should be dropped.
13+
| See: https://docs.scala-lang.org/scala3/reference/dropped-features/this-qualifier.html
14+
| This construct can be rewritten automatically under -rewrite -source 3.4-migration.

0 commit comments

Comments
 (0)