Skip to content

Commit d6bc491

Browse files
authored
Merge pull request #412 from scala/backport-lts-3.3-23115
Backport "patvar: adjust caret in error message" to 3.3 LTS
2 parents 5bd4644 + 4e1b2be commit d6bc491

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2971,7 +2971,7 @@ object Parsers {
29712971
| * variable pattern, e.g. `case x: String =>`
29722972
| * number literal pattern, e.g. `case 10.5: Double =>`
29732973
|are no longer supported. Remove the type ascription or move it to a separate variable pattern.""",
2974-
in.sourcePos(),
2974+
p.sourcePos,
29752975
warnFrom = `3.3`,
29762976
errorFrom = future
29772977
)

tests/neg/i15784.check

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
| Not found: A
1111
|
1212
| longer explanation available when compiling with `-explain`
13-
-- Warning: tests/neg/i15784.scala:7:8 ---------------------------------------------------------------------------------
13+
-- Warning: tests/neg/i15784.scala:7:7 ---------------------------------------------------------------------------------
1414
7 | case X: Int => X // warn
15-
| ^
16-
| Type ascriptions after patterns other than:
17-
| * variable pattern, e.g. `case x: String =>`
18-
| * number literal pattern, e.g. `case 10.5: Double =>`
19-
| are no longer supported. Remove the type ascription or move it to a separate variable pattern.
20-
-- Warning: tests/neg/i15784.scala:10:12 -------------------------------------------------------------------------------
15+
| ^
16+
| Type ascriptions after patterns other than:
17+
| * variable pattern, e.g. `case x: String =>`
18+
| * number literal pattern, e.g. `case 10.5: Double =>`
19+
| are no longer supported. Remove the type ascription or move it to a separate variable pattern.
20+
-- Warning: tests/neg/i15784.scala:10:7 --------------------------------------------------------------------------------
2121
10 | case `Int`: Int => `Int` // warn
22-
| ^
23-
| Type ascriptions after patterns other than:
24-
| * variable pattern, e.g. `case x: String =>`
25-
| * number literal pattern, e.g. `case 10.5: Double =>`
26-
| are no longer supported. Remove the type ascription or move it to a separate variable pattern.
22+
| ^^^^^
23+
| Type ascriptions after patterns other than:
24+
| * variable pattern, e.g. `case x: String =>`
25+
| * number literal pattern, e.g. `case 10.5: Double =>`
26+
| are no longer supported. Remove the type ascription or move it to a separate variable pattern.

tests/neg/t5702-neg-bad-and-wild.check

-7
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@
4646
| no pattern match extractor named * was found
4747
|
4848
| longer explanation available when compiling with `-explain`
49-
-- Warning: tests/neg/t5702-neg-bad-and-wild.scala:13:22 ---------------------------------------------------------------
50-
13 | case List(1, _*3:) => // error // error
51-
| ^
52-
| Type ascriptions after patterns other than:
53-
| * variable pattern, e.g. `case x: String =>`
54-
| * number literal pattern, e.g. `case 10.5: Double =>`
55-
| are no longer supported. Remove the type ascription or move it to a separate variable pattern.
5649
-- Warning: tests/neg/t5702-neg-bad-and-wild.scala:22:20 ---------------------------------------------------------------
5750
22 | val K(x @ _*) = k
5851
| ^

0 commit comments

Comments
 (0)