Skip to content

Commit aa0df6c

Browse files
committed
Suppress redundant "recursive value needs type" messages
1 parent 7c308d6 commit aa0df6c

File tree

7 files changed

+7
-19
lines changed

7 files changed

+7
-19
lines changed

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

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

tests/neg-macros/i6997b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import scala.quoted.*
55
inline def mcr(x: => Any): Any = ${mcrImpl('x)}
66

77
def mcrImpl(body: Expr[Any])(using ctx: Quotes): Expr[Any] = {
8-
val '{$x: $t} = body // error // error
8+
val '{$x: $t} = body // error
99
'{
1010
val tmp: $t = $x.asInstanceOf[$t] // error // error
1111
println(tmp)

tests/neg/i18020.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def foo1: Unit =
2424
// then Typer rejects "String" as an infix extractor (like ::)
2525
// which is the second error
2626

27-
def foo2: Unit = // error
27+
def foo2: Unit = // was: error, recursive value _root_ needs type
2828
val _root_ : String = "abc" // error
2929

3030
// i17757

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
@@ -31,7 +31,7 @@
3131
|
3232
| longer explanation available when compiling with `-explain`
3333
-- [E032] Syntax Error: tests/neg/t5702-neg-bad-and-wild.scala:23:17 ---------------------------------------------------
34-
23 | val K(ns @ _*, xx) = k // error: pattern expected // error
34+
23 | val K(ns @ _*, xx) = k // error: pattern expected
3535
| ^
3636
| pattern expected
3737
|
@@ -58,12 +58,6 @@
5858
| no pattern match extractor named * was found
5959
|
6060
| longer explanation available when compiling with `-explain`
61-
-- [E045] Cyclic Error: tests/neg/t5702-neg-bad-and-wild.scala:23:19 ---------------------------------------------------
62-
23 | val K(ns @ _*, xx) = k // error: pattern expected // error
63-
| ^
64-
| Recursive value $1$ needs type
65-
|
66-
| longer explanation available when compiling with `-explain`
6761
-- Warning: tests/neg/t5702-neg-bad-and-wild.scala:13:22 ---------------------------------------------------------------
6862
13 | case List(1, _*3:) => // error // error
6963
| ^

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) // error: bad use of `*`
2626
// no longer complains

0 commit comments

Comments
 (0)