Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Wperformance lints *Ref boxing and nonlocal return
-Xlint:nonlocal-return is supported for compatibility.
- Loading branch information
Showing
11 changed files
with
49 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// scalac: -Xfatal-warnings -Xlint:nonlocal-return | ||
// scalac: -Werror -Wperformance | ||
// | ||
|
||
import util.Try | ||
|
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,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. | ||
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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) | ||
} |
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
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
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,17 +1,13 @@ | ||
//scalac: -Xlint:-nonlocal-return | ||
object Test { | ||
def f(): Int = { | ||
try { | ||
val g = (1 to 10 map { i => return 16 ; i }).sum | ||
g | ||
} | ||
catch { case x: runtime.NonLocalReturnControl[_] => | ||
println(x.getClass.getName) | ||
x.value.asInstanceOf[Int] | ||
try (1 to 10).map { i => return 16 ; i }.sum | ||
catch { | ||
case x: runtime.NonLocalReturnControl[_] => | ||
assert(x.getClass.getName == "scala.runtime.NonLocalReturnControl$mcI$sp") | ||
x.value.asInstanceOf[Int] | ||
} | ||
} | ||
|
||
def main(args: Array[String]): Unit = { | ||
println(f()) | ||
} | ||
def main(args: Array[String]): Unit = assert(f() == 16) | ||
} |