summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-02-19 20:45:45 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-02-19 20:45:47 -0800
commit07e0e2f92f9208c0b582d7cfd355d7574217cc23 (patch)
tree33623ce875e519ed5d48f9fb7633f17b754410a9 /src/library
parent2ead4d6aa3de402f269252190aaa9075a990e098 (diff)
downloadscala-07e0e2f92f9208c0b582d7cfd355d7574217cc23.tar.gz
scala-07e0e2f92f9208c0b582d7cfd355d7574217cc23.tar.bz2
scala-07e0e2f92f9208c0b582d7cfd355d7574217cc23.zip
SI-5479 deprecate DelayedInit outside of App
DelayedInit's semantics are way too surprising. For example, it delays initialization of fields, so that fields on objects that extend `App` (which `extends DelayedInit`) are not initialized until the `main` method is called. For more details and a proposed alternative, see https://issues.scala-lang.org/browse/SI-4330?jql=labels%20%3D%20delayedinit%20AND%20resolution%20%3D%20unresolved. Support for `App` will continue -- we'll special case it.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/App.scala5
-rw-r--r--src/library/scala/DelayedInit.scala1
2 files changed, 6 insertions, 0 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..e412ac9d26 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.\n(For details and a proposed alternative, see https://issues.scala-lang.org/browse/SI-4330?jql=labels%20%3D%20delayedinit%20AND%20resolution%20%3D%20unresolved. Support for `App` will continue.)", "2.11.0")
trait DelayedInit {
def delayedInit(x: => Unit): Unit
} \ No newline at end of file