-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
121 additions
and
9 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 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
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,22 @@ | ||
-- Warning: tests/warn/i22527.scala:60:10 ------------------------------------------------------------------------------ | ||
60 | y, // warn | ||
| ^ | ||
| Line is indented too far to the left, or a ')' is missing | ||
-- Warning: tests/warn/i22527.scala:61:10 ------------------------------------------------------------------------------ | ||
61 | z, // warn | ||
| ^ | ||
| Line is indented too far to the left, or a ')' is missing | ||
-- Warning: tests/warn/i22527.scala:72:2 ------------------------------------------------------------------------------- | ||
72 | 42 // warn | ||
| ^ | ||
| Line is indented too far to the left, or a ')' is missing | ||
-- Warning: tests/warn/i22527.scala:79:0 ------------------------------------------------------------------------------- | ||
79 |k: // warn | ||
|^ | ||
|Line is indented too far to the left, or a ')' is missing | ||
-- [E190] Potential Issue Warning: tests/warn/i22527.scala:40:6 -------------------------------------------------------- | ||
40 | true, "fail") // warn value discard | ||
| ^^^^ | ||
| Discarded non-Unit value of type Boolean. Add `: Unit` to discard silently. | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,81 @@ | ||
|
||
def f: Unit = | ||
identity( | ||
identity: | ||
class X extends AnyRef, Serializable | ||
42 | ||
) | ||
|
||
def test: Unit = | ||
assert( | ||
identity: | ||
true, | ||
"ok" | ||
) | ||
|
||
def toss: Unit = | ||
assert( | ||
throw | ||
null, | ||
"ok" | ||
) | ||
def raise: Unit = | ||
assert( | ||
throw | ||
null, "ok" // ok now | ||
) | ||
|
||
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, // warn | ||
z, // warn | ||
) | ||
) | ||
|
||
object `arrow eol`: | ||
def f(g: Int => Int, i: Int): Int = g(i) | ||
def g(map: Int => Int): Int => Int = map | ||
def k(i: => Int) = i | ||
def test = | ||
f( | ||
g(_ + 1), | ||
42 // warn | ||
) | ||
def test2 = | ||
f( | ||
g: | ||
x => | ||
x + 1, | ||
k: // warn | ||
42 | ||
) |