Skip to content

Commit a92473b

Browse files
authored
Merge pull request #9547 from dotty-staging/fix-#9266
Fix #9266: Offer rewrites for parentheses in implicit closures
2 parents db935a8 + fd25344 commit a92473b

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,11 +2169,11 @@ object Parsers {
21692169
// Don't error in non-strict mode, as the alternative syntax "implicit (x: T) => ... "
21702170
// is not supported by Scala2.x
21712171
report.errorOrMigrationWarning(
2172-
s"This syntax is no longer supported; parameter needs to be enclosed in (...)",
2173-
in.sourcePos())
2172+
s"This syntax is no longer supported; parameter needs to be enclosed in (...)${rewriteNotice()}",
2173+
source.atSpan(Span(start, in.lastOffset)))
21742174
in.nextToken()
21752175
val t = infixType()
2176-
if (false && migrateTo3) {
2176+
if (sourceVersion == `3.1-migration`) {
21772177
patch(source, Span(start), "(")
21782178
patch(source, Span(in.lastOffset), ")")
21792179
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/neg-custom-args/fatal-warnings/i9266.scala:3:22 --------------------------------------------------------
2+
3 |def test = { implicit x: Int => x + x } // error
3+
| ^
4+
| This syntax is no longer supported; parameter needs to be enclosed in (...)
5+
| This construct can be rewritten automatically under -rewrite.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import language.`3.1-migration`
2+
3+
def test = { implicit x: Int => x + x } // error

tests/pos/i9266.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import language.`3.1-migration`
2+
3+
def test = { implicit x: Int => x + x }

0 commit comments

Comments
 (0)