forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
case
in pattern bindings even without -Xsource:3
In scala#9558 (which shipped with 2.13.6) we added support for `case` bindings under -Xsource:3. Since this parser change does not break any existing code and since IntelliJ and scalameta/metals now understand this syntax in Scala 2 code, it should be safe to enable it by default to further ease cross-compilation between Scala 2 and 3.
- Loading branch information
Showing
5 changed files
with
17 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
for-comprehension-case.scala:5: error: `case` keyword in for comprehension requires the -Xsource:3 flag. | ||
case Some(x) <- List(Some(1), None) | ||
^ | ||
for-comprehension-case.scala:12: error: `case` keyword in for comprehension requires the -Xsource:3 flag. | ||
case y = x + 1 | ||
^ | ||
for-comprehension-case.scala:12: error: '<-' expected but '=' found. | ||
for-comprehension-case.scala:20: error: '<-' expected but '=' found. | ||
case y = x + 1 | ||
^ | ||
for-comprehension-case.scala:13: error: illegal start of simple expression | ||
} yield x+y | ||
for-comprehension-case.scala:21: error: illegal start of simple expression | ||
} yield x + y | ||
^ | ||
4 errors | ||
2 errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
class A { | ||
// fail | ||
// ok | ||
val a = | ||
for { | ||
case Some(x) <- List(Some(1), None) | ||
} yield x | ||
y = x + 1 | ||
} yield x + y | ||
|
||
// fail | ||
// ok | ||
val b = | ||
for { | ||
Some(x) <- List(Some(1), None) | ||
case y = x + 1 | ||
Some(y) <- List(None, Some(2)) | ||
} yield x+y | ||
|
||
// fail | ||
val c = | ||
for { | ||
case Some(x) <- List(Some(1), None) | ||
case y = x + 1 | ||
} yield x + y | ||
} |