diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-02-22 14:43:07 +0100 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2014-02-22 14:43:07 +0100 |
commit | b0dcf798752220c7fe173318930215248aa0bfbb (patch) | |
tree | 7a85990f10e59cc8b7a8fafd34d4feff5d17cafd | |
parent | 63d4dfaf7cf25f2cf5c00c97986d3d060733268f (diff) | |
parent | 2ede59c0b9d12d47a1f61d1c599842856d829227 (diff) | |
download | scala-b0dcf798752220c7fe173318930215248aa0bfbb.tar.gz scala-b0dcf798752220c7fe173318930215248aa0bfbb.tar.bz2 scala-b0dcf798752220c7fe173318930215248aa0bfbb.zip |
Merge pull request #3563 from adriaanm/t5479
SI-5479 deprecate DelayedInit outside of App
-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/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 |
8 files changed, 16 insertions, 2 deletions
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/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 |