Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Potentially annoying lints for -Wperformance
- Loading branch information
Showing
3 changed files
with
22 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
xlint-captured.scala:10: warning: return statement uses an exception to pass control to the caller of the enclosing named method f | ||
def f(): Unit = List(42).foreach(i => if (i > 27) return) | ||
^ | ||
xlint-captured.scala:5: warning: Modification of variable c within a closure causes it to be boxed. | ||
var c = a // nok | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
1 warning | ||
2 warnings | ||
1 error |
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,9 +1,11 @@ | ||
// scalac: -Werror -Xlint:captured | ||
// scalac: -Werror -Wperformance | ||
object Test { | ||
var a, b = 0 // ok | ||
def mkStrangeCounter(): Int => Int = { | ||
var c = a // nok | ||
object _d { var d = b }; import _d._ // ok | ||
e => { c += a; d += b; a *= b; b -= c; c ^ d } | ||
} | ||
|
||
def f(): Unit = List(42).foreach(i => if (i > 27) return) | ||
} |