diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-19 20:45:45 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-19 20:45:47 -0800 |
commit | 07e0e2f92f9208c0b582d7cfd355d7574217cc23 (patch) | |
tree | 33623ce875e519ed5d48f9fb7633f17b754410a9 /test/files | |
parent | 2ead4d6aa3de402f269252190aaa9075a990e098 (diff) | |
download | scala-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 'test/files')
-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 |
6 files changed, 10 insertions, 2 deletions
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 |