diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala | 2 | ||||
-rw-r--r-- | src/library/scala/App.scala | 5 | ||||
-rw-r--r-- | src/library/scala/DelayedInit.scala | 1 | ||||
-rw-r--r-- | test/files/neg/delayed-init-ref.check | 6 | ||||
-rw-r--r-- | test/files/neg/delayed-init-ref.flags | 2 | ||||
-rw-r--r-- | test/files/pos/t8315.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t8315.scala | 12 | ||||
-rw-r--r-- | test/files/pos/t8315b.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t8315b.scala | 11 | ||||
-rw-r--r-- | test/files/run/delay-bad.check | 1 | ||||
-rw-r--r-- | test/files/run/t4396.check | 1 | ||||
-rw-r--r-- | test/files/run/t4680.check | 1 | ||||
-rw-r--r-- | test/files/run/t6481.check | 1 |
14 files changed, 44 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 03b76ed99e..6b14461cac 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1798,10 +1798,8 @@ class Global(var currentSettings: Settings, var reporter: Reporter) private def writeICode() { val printer = new icodes.TextPrinter(null, icodes.linearizer) icodes.classes.values.foreach((cls) => { - val suffix = if (cls.symbol.hasModuleFlag) "$.icode" else ".icode" + val suffix = s"${if (cls.symbol.hasModuleFlag) "$" else ""}_${phase}.icode" val file = getFile(cls.symbol, suffix) -// if (file.exists()) -// file = new File(file.getParentFile(), file.getName() + "1") try { val stream = new FileOutputStream(file) printer.setWriter(new PrintWriter(stream, true)) diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala index 0f317422ac..b39fee65bb 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala @@ -95,8 +95,10 @@ abstract class DeadCodeElimination extends SubComponent { localStores.clear() clobbers.clear() m.code.blocks.clear() + m.code.touched = true accessedLocals = m.params.reverse m.code.blocks ++= linearizer.linearize(m) + m.code.touched = true collectRDef(m) mark() sweep(m) diff --git a/src/library/scala/App.scala b/src/library/scala/App.scala index ef39ee2134..62245322da 100644 --- a/src/library/scala/App.scala +++ b/src/library/scala/App.scala @@ -31,6 +31,8 @@ import scala.collection.mutable.ListBuffer * It should also be noted that the `main` method should not be overridden: * the whole class body becomes the “main method”. * + * Future versions of this trait will no longer extend `DelayedInit`. + * * @author Martin Odersky * @version 2.1, 15/02/2011 */ @@ -38,10 +40,12 @@ trait App extends DelayedInit { /** The time when the execution of this program started, in milliseconds since 1 * January 1970 UTC. */ + @deprecatedOverriding("executionStart should not be overridden", "2.11.0") val executionStart: Long = currentTime /** The command line arguments passed to the application's `main` method. */ + @deprecatedOverriding("args should not be overridden", "2.11.0") protected def args: Array[String] = _args private var _args: Array[String] = _ @@ -55,6 +59,7 @@ trait App extends DelayedInit { * themselves define a `delayedInit` method. * @param body the initialization code to be stored for later execution */ + @deprecated("The delayedInit mechanism will disappear.", "2.11.0") override def delayedInit(body: => Unit) { initCode += (() => body) } diff --git a/src/library/scala/DelayedInit.scala b/src/library/scala/DelayedInit.scala index cfbbf30793..7f976b073f 100644 --- a/src/library/scala/DelayedInit.scala +++ b/src/library/scala/DelayedInit.scala @@ -43,6 +43,7 @@ package scala * * @author Martin Odersky */ +@deprecated("DelayedInit semantics can be surprising. Support for `App` will continue.\nSee the release notes for more details: https://github.com/scala/scala/releases/tag/v2.11.0-RC1", "2.11.0") trait DelayedInit { def delayedInit(x: => Unit): Unit }
\ No newline at end of file diff --git a/test/files/neg/delayed-init-ref.check b/test/files/neg/delayed-init-ref.check index ce5b205832..90bc027969 100644 --- a/test/files/neg/delayed-init-ref.check +++ b/test/files/neg/delayed-init-ref.check @@ -4,9 +4,13 @@ delayed-init-ref.scala:17: warning: Selecting value vall from object O, which ex delayed-init-ref.scala:19: warning: Selecting value vall from object O, which extends scala.DelayedInit, is likely to yield an uninitialized value println(vall) // warn ^ +delayed-init-ref.scala:28: warning: trait DelayedInit in package scala is deprecated: DelayedInit semantics can be surprising. Support for `App` will continue. +See the release notes for more details: https://github.com/scala/scala/releases/tag/v2.11.0-RC1 +trait Before extends DelayedInit { + ^ delayed-init-ref.scala:40: warning: Selecting value foo from trait UserContext, which extends scala.DelayedInit, is likely to yield an uninitialized value println({locally(()); this}.foo) // warn (spurious, but we can't discriminate) ^ error: No warnings can be incurred under -Xfatal-warnings. -three warnings found +four warnings found one error found diff --git a/test/files/neg/delayed-init-ref.flags b/test/files/neg/delayed-init-ref.flags index 7949c2afa2..88a3e4c676 100644 --- a/test/files/neg/delayed-init-ref.flags +++ b/test/files/neg/delayed-init-ref.flags @@ -1 +1 @@ --Xlint -Xfatal-warnings +-deprecation -Xlint -Xfatal-warnings diff --git a/test/files/pos/t8315.flags b/test/files/pos/t8315.flags new file mode 100644 index 0000000000..c926ad6493 --- /dev/null +++ b/test/files/pos/t8315.flags @@ -0,0 +1 @@ +-Yinline -Ydead-code diff --git a/test/files/pos/t8315.scala b/test/files/pos/t8315.scala new file mode 100644 index 0000000000..2f7742ed67 --- /dev/null +++ b/test/files/pos/t8315.scala @@ -0,0 +1,12 @@ +object Test { + def crash(as: Listt): Unit = { + map(as, (_: Any) => return) + } + + final def map(x: Listt, f: Any => Any): Any = { + if (x eq Nill) "" else f("") + } +} + +object Nill extends Listt +class Listt diff --git a/test/files/pos/t8315b.flags b/test/files/pos/t8315b.flags new file mode 100644 index 0000000000..c926ad6493 --- /dev/null +++ b/test/files/pos/t8315b.flags @@ -0,0 +1 @@ +-Yinline -Ydead-code diff --git a/test/files/pos/t8315b.scala b/test/files/pos/t8315b.scala new file mode 100644 index 0000000000..d7a2bf565f --- /dev/null +++ b/test/files/pos/t8315b.scala @@ -0,0 +1,11 @@ +object Test extends Object { + def crash: Unit = { + val key = "" + try map(new F(key)) + catch { case _: Throwable => } + }; + final def map(f: F): Any = f.apply(""); +}; +final class F(key: String) { + final def apply(a: Any): Any = throw new RuntimeException(key); +} diff --git a/test/files/run/delay-bad.check b/test/files/run/delay-bad.check index 2ae88267c5..5d8c5fa1d4 100644 --- a/test/files/run/delay-bad.check +++ b/test/files/run/delay-bad.check @@ -4,6 +4,7 @@ delay-bad.scala:53: warning: a pure expression does nothing in statement positio delay-bad.scala:73: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses f(new { val x = 5 } with E() { 5 }) ^ +warning: there were 1 deprecation warning(s); re-run with -deprecation for details // new C { } diff --git a/test/files/run/t4396.check b/test/files/run/t4396.check index 58f4fc5138..a75e1f257f 100644 --- a/test/files/run/t4396.check +++ b/test/files/run/t4396.check @@ -1,3 +1,4 @@ +warning: there were 1 deprecation warning(s); re-run with -deprecation for details hallo constructor out:22 diff --git a/test/files/run/t4680.check b/test/files/run/t4680.check index b2e5209dc5..512bfd4b54 100644 --- a/test/files/run/t4680.check +++ b/test/files/run/t4680.check @@ -4,6 +4,7 @@ t4680.scala:51: warning: a pure expression does nothing in statement position; y t4680.scala:69: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses new { val x = 5 } with E() { 5 } ^ +warning: there were 1 deprecation warning(s); re-run with -deprecation for details // new C { } diff --git a/test/files/run/t6481.check b/test/files/run/t6481.check index 7ec29631b1..df40722242 100644 --- a/test/files/run/t6481.check +++ b/test/files/run/t6481.check @@ -1,3 +1,4 @@ +warning: there were 1 deprecation warning(s); re-run with -deprecation for details delayed init new foo(1, 2) delayed init |