summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/App.scala5
-rw-r--r--src/library/scala/DelayedInit.scala1
-rw-r--r--test/files/neg/delayed-init-ref.check6
-rw-r--r--test/files/neg/delayed-init-ref.flags2
-rw-r--r--test/files/run/delay-bad.check1
-rw-r--r--test/files/run/t4396.check1
-rw-r--r--test/files/run/t4680.check1
-rw-r--r--test/files/run/t6481.check1
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..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
diff --git a/test/files/neg/delayed-init-ref.check b/test/files/neg/delayed-init-ref.check
index ce5b205832..63ed5843fc 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.
+(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.)
+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