From 72bce19b21e73d0e7e0e3036f1f67d241362c39c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Rochala?= <48657087+rochala@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:32:59 +0200 Subject: [PATCH] SimplePattern errors should now be recovered as wildcard instead of unimplemented expr (#21438) We should not emit more errors that came from our error recovery term trees. Previously, we've recovered those situations with unimplemented expression term added in https://github.com/scala/scala3/pull/19103 and before that it was just a `null` [Cherry-picked f036195971c6c848df9cbe01af5ec5a967757c32] --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 2 +- tests/neg/i5004.scala | 2 +- tests/neg/parser-stability-1.scala | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 8778c099c5aa..e11cd211157b 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3035,7 +3035,7 @@ object Parsers { else { val start = in.lastOffset syntaxErrorOrIncomplete(IllegalStartOfSimplePattern(), expectedOffset) - errorTermTree(start) + atSpan(Span(start, in.offset)) { Ident(nme.WILDCARD) } } } diff --git a/tests/neg/i5004.scala b/tests/neg/i5004.scala index 02105104efd1..ba1abe77f5bf 100644 --- a/tests/neg/i5004.scala +++ b/tests/neg/i5004.scala @@ -2,5 +2,5 @@ object i0 { 1 match { def this(): Int // error def this() -} // error +} } diff --git a/tests/neg/parser-stability-1.scala b/tests/neg/parser-stability-1.scala index 661ab87e31e5..560b9cf116e3 100644 --- a/tests/neg/parser-stability-1.scala +++ b/tests/neg/parser-stability-1.scala @@ -1,4 +1,3 @@ object x0 { x1 match // error def this // error -// error \ No newline at end of file