Skip to content

Commit e2f8f4d

Browse files
committed
Fix #9266: Offer rewrites for parentheses in implicit closures
I don't have the time to write a proper test for this. I verified manually that it does what it should: ``` -- Migration Warning: i9266.scala:3:23 ----------------------------------------- 3 |def test = { implicit x: Int => x + x } | ^ |This syntax is no longer supported; parameter needs to be enclosed in (...) |This construct can be rewritten automatically under -rewrite. 1 warning found ```
1 parent 28069b6 commit e2f8f4d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 2 additions & 2 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 (...)",
2172+
s"This syntax is no longer supported; parameter needs to be enclosed in (...)${rewriteNotice()}",
21732173
in.sourcePos())
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
}

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)