forked from scala/scala3
-
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.
Restrict outdent in parens for certain region prefixes
- Loading branch information
Showing
3 changed files
with
97 additions
and
1 deletion.
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 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
//rule of thumb is COLONeol was at EOL, so COMMA must be at EOL | ||
def test: Unit = | ||
assert( | ||
identity: | ||
true, "ok" // error end of statement expected but ',' found | ||
) | ||
|
||
def toss: Unit = | ||
assert( | ||
throw | ||
null, "ok" // error same | ||
) | ||
|
||
def callme[A](x: => A, msg: String) = try x.toString catch case t: RuntimeException => msg | ||
|
||
// not all indented regions require COMMA at EOL for OUTDENT | ||
def orElse(x: Int): Unit = | ||
callme( | ||
if x > 0 then | ||
class X extends AnyRef, Serializable // error Not found: Serializable - did you mean Specializable? | ||
true // error ',' or ')' expected, but 'true' found | ||
else | ||
false, "fail") |
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
def f: Unit = | ||
identity( | ||
identity: | ||
class X extends AnyRef, Serializable | ||
42 | ||
) | ||
|
||
def g: Unit = | ||
identity( | ||
x = | ||
class X extends AnyRef, Serializable | ||
27 | ||
) | ||
|
||
def test: Unit = | ||
assert( | ||
identity: | ||
true, | ||
"ok" | ||
) | ||
|
||
def toss: Unit = | ||
assert( | ||
throw | ||
null, | ||
"ok" | ||
) | ||
|
||
def callme[A](x: => A, msg: String) = try x.toString catch case t: RuntimeException => msg | ||
|
||
def orElse(x: Int): Unit = | ||
callme( | ||
if x > 0 then | ||
true | ||
else | ||
false, "fail") | ||
|
||
def onlyIf(x: Int): Unit = | ||
callme( | ||
if (x > 0) | ||
true, "fail") // warn value discard | ||
|
||
def h(xs: List[Int]) = | ||
xs.foldLeft(0) | ||
( | ||
(acc, x) => | ||
acc | ||
+ x, | ||
) | ||
|
||
def sum(x: Int, y: Int, z: Int) = x+y+z | ||
|
||
def k(xs: List[Int], y: Int, z: Int) = | ||
xs.foldLeft(0) | ||
( | ||
(acc, x) => | ||
sum( | ||
x | ||
+ y | ||
+ z, | ||
y, | ||
z, | ||
) | ||
) |