Skip to content

Commit 6440434

Browse files
committed
Suppress redundant "recursive value needs type" messages
[Cherry-picked aa0df6c][modified]
1 parent d53cbac commit 6440434

File tree

5 files changed

+5
-17
lines changed

5 files changed

+5
-17
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3102,7 +3102,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
31023102
case ex: CyclicReference
31033103
if ctx.reporter.errorsReported
31043104
&& xtree.span.isZeroExtent
3105-
&& ex.isVal && false =>
3105+
&& ex.isVal =>
31063106
// Don't report a "recursive val ... needs type" if errors were reported
31073107
// previously and the span of the offending tree is empty. In this case,
31083108
// it's most likely that this is desugared code, and the error message would

tests/neg/i18684.check

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,8 @@
1717
|
1818
| longer explanation available when compiling with `-explain`
1919
-- [E127] Pattern Match Error: tests/neg/i18684.scala:12:6 -------------------------------------------------------------
20-
12 | val inner(x) = 3 // error // error
20+
12 | val inner(x) = 3 // error
2121
| ^^^^^
2222
| Test.inner cannot be used as an extractor in a pattern because it lacks an unapply or unapplySeq method
2323
|
2424
| longer explanation available when compiling with `-explain`
25-
-- [E045] Cyclic Error: tests/neg/i18684.scala:12:14 -------------------------------------------------------------------
26-
12 | val inner(x) = 3 // error // error
27-
| ^
28-
| Recursive value x needs type
29-
|
30-
| longer explanation available when compiling with `-explain`

tests/neg/i18684.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ object Test:
99
object inner:
1010
val foo() = "33" // error
1111

12-
val inner(x) = 3 // error // error
12+
val inner(x) = 3 // error

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
|
2828
| longer explanation available when compiling with `-explain`
2929
-- [E032] Syntax Error: tests/neg/t5702-neg-bad-and-wild.scala:23:17 ---------------------------------------------------
30-
23 | val K(ns @ _*, xx) = k // error: pattern expected // error
30+
23 | val K(ns @ _*, xx) = k // error: pattern expected
3131
| ^
3232
| pattern expected
3333
|
@@ -50,12 +50,6 @@
5050
| no pattern match extractor named * was found
5151
|
5252
| longer explanation available when compiling with `-explain`
53-
-- [E045] Cyclic Error: tests/neg/t5702-neg-bad-and-wild.scala:23:19 ---------------------------------------------------
54-
23 | val K(ns @ _*, xx) = k // error: pattern expected // error
55-
| ^
56-
| Recursive value $1$ needs type
57-
|
58-
| longer explanation available when compiling with `-explain`
5953
-- Warning: tests/neg/t5702-neg-bad-and-wild.scala:13:22 ---------------------------------------------------------------
6054
13 | case List(1, _*3:) => // error // error
6155
| ^

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object Test {
2020
// good syntax, bad semantics, detected by typer
2121
//gowild.scala:14: error: star patterns must correspond with varargs parameters
2222
val K(x @ _*) = k
23-
val K(ns @ _*, xx) = k // error: pattern expected // error
23+
val K(ns @ _*, xx) = k // error: pattern expected
2424
val K(x) = k // error: x is already defined as value x
2525
val (b, _ * ) = (5,6) // ok
2626
// no longer complains

0 commit comments

Comments
 (0)