From 879e5af47db2ae6807aef26dd786e6ea920ac554 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 10 Aug 2011 00:55:15 +0000 Subject: Reversed the values of "is" and "is not" in rec... Reversed the values of "is" and "is not" in recent for comprehension deprecation. DO NOT BLOW HATCH REPEAT DO NOT BLOW HATCH "Roger! Hatch blown." Events reveal it was all baby, no bathwater. It turns out that the specification is merely a document, not infallible holy writ as we had all previously believed. So it is not the ABSENCE of val in a for comprehension assignment which is deprecated, it is the PRESENCE of val. Summarizing again, more accurately perhaps: for (x <- 1 to 5 ; y = x) yield x+y // THAT's the one for (val x <- 1 to 5 ; y = x) yield x+y // fail for (val x <- 1 to 5 ; val y = x) yield x+y // fail for (x <- 1 to 5 ; val y = x) yield x+y // deprecated No review. --- test/files/neg/for-comprehension-old.check | 24 ++++++++++++------------ test/files/neg/for-comprehension-old.scala | 8 ++++---- test/files/neg/t4163.check | 6 +++--- test/files/neg/t4163.scala | 10 +++++----- test/files/pos/bug252.scala | 2 +- test/files/pos/t2413/TestScalac.scala | 2 +- test/files/positions/Unpositioned1.scala | 2 +- test/files/res/bug831/NewScalaParserXXX.scala | 2 +- test/files/run/fors.scala | 4 ++-- test/files/run/forvaleq.scala | 14 +++++++------- test/files/run/mapConserve.scala | 2 +- test/files/run/repl-suppressed-warnings.check | 25 ++++++++++++++++--------- test/files/run/repl-suppressed-warnings.scala | 7 ++++++- test/files/run/sequenceComparisons.scala | 4 ++-- test/files/run/t1939.scala | 2 +- 15 files changed, 63 insertions(+), 51 deletions(-) (limited to 'test') diff --git a/test/files/neg/for-comprehension-old.check b/test/files/neg/for-comprehension-old.check index 783354d233..1ecaf12af4 100644 --- a/test/files/neg/for-comprehension-old.check +++ b/test/files/neg/for-comprehension-old.check @@ -1,15 +1,15 @@ -for-comprehension-old.scala:2: warning: for comprehension assignment without a `val' declaration is deprecated. - for (x <- 1 to 5 ; y = x) yield x+y // fail - ^ -for-comprehension-old.scala:4: warning: for comprehension assignment without a `val' declaration is deprecated. - for (val x <- 1 to 5 ; y = x) yield x+y // fail - ^ -for-comprehension-old.scala:7: warning: for comprehension assignment without a `val' declaration is deprecated. - for (z <- 1 to 2 ; x <- 1 to 5 ; y = x) yield x+y // fail - ^ -for-comprehension-old.scala:9: warning: for comprehension assignment without a `val' declaration is deprecated. - for (z <- 1 to 2 ; val x <- 1 to 5 ; y = x) yield x+y // fail - ^ +for-comprehension-old.scala:3: warning: val keyword in for comprehension is deprecated + for (x <- 1 to 5 ; val y = x) yield x+y // fail + ^ +for-comprehension-old.scala:5: warning: val keyword in for comprehension is deprecated + for (val x <- 1 to 5 ; val y = x) yield x+y // fail + ^ +for-comprehension-old.scala:8: warning: val keyword in for comprehension is deprecated + for (z <- 1 to 2 ; x <- 1 to 5 ; val y = x) yield x+y // fail + ^ +for-comprehension-old.scala:10: warning: val keyword in for comprehension is deprecated + for (z <- 1 to 2 ; val x <- 1 to 5 ; val y = x) yield x+y // fail + ^ for-comprehension-old.scala:4: error: val in for comprehension must be followed by assignment for (val x <- 1 to 5 ; y = x) yield x+y // fail ^ diff --git a/test/files/neg/for-comprehension-old.scala b/test/files/neg/for-comprehension-old.scala index 476e99808e..10ae363bde 100644 --- a/test/files/neg/for-comprehension-old.scala +++ b/test/files/neg/for-comprehension-old.scala @@ -1,11 +1,11 @@ class A { - for (x <- 1 to 5 ; y = x) yield x+y // fail - for (x <- 1 to 5 ; val y = x) yield x+y // ok + for (x <- 1 to 5 ; y = x) yield x+y // ok + for (x <- 1 to 5 ; val y = x) yield x+y // fail for (val x <- 1 to 5 ; y = x) yield x+y // fail for (val x <- 1 to 5 ; val y = x) yield x+y // fail - for (z <- 1 to 2 ; x <- 1 to 5 ; y = x) yield x+y // fail - for (z <- 1 to 2 ; x <- 1 to 5 ; val y = x) yield x+y // ok + for (z <- 1 to 2 ; x <- 1 to 5 ; y = x) yield x+y // ok + for (z <- 1 to 2 ; x <- 1 to 5 ; val y = x) yield x+y // fail for (z <- 1 to 2 ; val x <- 1 to 5 ; y = x) yield x+y // fail for (z <- 1 to 2 ; val x <- 1 to 5 ; val y = x) yield x+y // fail } diff --git a/test/files/neg/t4163.check b/test/files/neg/t4163.check index e94c4fae7c..47bc78d31c 100644 --- a/test/files/neg/t4163.check +++ b/test/files/neg/t4163.check @@ -1,7 +1,7 @@ t4163.scala:4: error: '<-' expected but '=' found. - val x = 3 - ^ + x = 3 + ^ t4163.scala:5: error: illegal start of simple expression - y <- 0 to 100 + y <- 0 to 100 ^ two errors found diff --git a/test/files/neg/t4163.scala b/test/files/neg/t4163.scala index bb4c65f18d..44686731d1 100644 --- a/test/files/neg/t4163.scala +++ b/test/files/neg/t4163.scala @@ -1,8 +1,8 @@ class Bug { val z = ( - for { - val x = 3 - y <- 0 to 100 - } yield y - ).toArray + for { + x = 3 + y <- 0 to 100 + } yield y + ).toArray } diff --git a/test/files/pos/bug252.scala b/test/files/pos/bug252.scala index b10811fb1f..d51b5511eb 100644 --- a/test/files/pos/bug252.scala +++ b/test/files/pos/bug252.scala @@ -12,6 +12,6 @@ abstract class Base { abstract class Derived extends Base { def f(inputs: List[tType]): Unit = { - for (t <- inputs; val m = t.module) { } + for (t <- inputs; m = t.module) { } } } diff --git a/test/files/pos/t2413/TestScalac.scala b/test/files/pos/t2413/TestScalac.scala index 0f395e6c74..098e852dd7 100644 --- a/test/files/pos/t2413/TestScalac.scala +++ b/test/files/pos/t2413/TestScalac.scala @@ -18,6 +18,6 @@ class Foo extends TestJava { val aVal = repeatParam("1","2","3") */ // THIS YIELDS TO CRASH - for (a <- 1 to 4 ; val anotherVal = repeatParam("1","2","3")) + for (a <- 1 to 4 ; anotherVal = repeatParam("1","2","3")) yield anotherVal } diff --git a/test/files/positions/Unpositioned1.scala b/test/files/positions/Unpositioned1.scala index 7fc520e93c..174db901da 100644 --- a/test/files/positions/Unpositioned1.scala +++ b/test/files/positions/Unpositioned1.scala @@ -1,3 +1,3 @@ object Unpositioned1 { - for (a <- Some("foo") ; val b = true) {} + for (a <- Some("foo") ; b = true) {} } diff --git a/test/files/res/bug831/NewScalaParserXXX.scala b/test/files/res/bug831/NewScalaParserXXX.scala index 88c81637f0..e5af487def 100644 --- a/test/files/res/bug831/NewScalaParserXXX.scala +++ b/test/files/res/bug831/NewScalaParserXXX.scala @@ -7,7 +7,7 @@ trait ScalaNodeScannerXXX { trait UnfixedImpl extends NodeImpl { def self : Unfixed; } } //def f = { Console.println("hello"); 42; } -//for (val ns <-n; val i <- 0.until(ns)) yield f; +//for (ns <-n; val i <- 0.until(ns)) yield f; trait NewScalaScannerXXX extends ScalaNodeScannerXXX { diff --git a/test/files/run/fors.scala b/test/files/run/fors.scala index c7682f563d..54afdc710b 100644 --- a/test/files/run/fors.scala +++ b/test/files/run/fors.scala @@ -76,10 +76,10 @@ object Test extends App { for {x <- it if x % 2 == 0} print(x + " "); println for (x <- it; - val y = 2 + y = 2 if x % y == 0) print(x + " "); println for {x <- it - val y = 2 + y = 2 if x % y == 0} print(x + " "); println // arrays diff --git a/test/files/run/forvaleq.scala b/test/files/run/forvaleq.scala index 40dbfd099a..8c1824a769 100644 --- a/test/files/run/forvaleq.scala +++ b/test/files/run/forvaleq.scala @@ -24,7 +24,7 @@ object Test { val input = L.range(0,20) val oddFirstTimesTwo = for {x <- input - val xf = firstDigit(x) + xf = firstDigit(x) if xf % 2 == 1} yield x*2 println(oddFirstTimesTwo) @@ -36,9 +36,9 @@ object Test { val input = L.range(0, 20) val oddFirstTimesTwo = for {x <- input - val xf = firstDigit(x) - val yf = x - firstDigit(x) / 10 - val (a, b) = (xf - yf, xf + yf) + xf = firstDigit(x) + yf = x - firstDigit(x) / 10 + (a, b) = (xf - yf, xf + yf) if xf % 2 == 1} yield a + b println(oddFirstTimesTwo) @@ -51,7 +51,7 @@ object Test { val input = L.range(0, 20).iterator val oddFirstTimesTwo = for {x <- input - val xf = firstDigit(x) + xf = firstDigit(x) if xf % 2 == 1} yield x*2 println(oddFirstTimesTwo.toList) @@ -63,7 +63,7 @@ object Test { val input = L.range(0,20) val oddFirstTimesTwo = for {x <- input - val xf = firstDigit(x) + xf = firstDigit(x) if xf % 2 == 1} yield xf*2 println(oddFirstTimesTwo) @@ -80,7 +80,7 @@ object Test { val input = L.range(0,20) for {x <- input - val xf = fdct(x) + xf = fdct(x) if xf % 2 == 1} yield xf diff --git a/test/files/run/mapConserve.scala b/test/files/run/mapConserve.scala index 176e38bed4..a285113b11 100644 --- a/test/files/run/mapConserve.scala +++ b/test/files/run/mapConserve.scala @@ -30,7 +30,7 @@ object Test { def main(args: Array[String]) { for (length <- 0 to maxListLength; bitmap <- 0 until (1 << length); - val data = List.range(0, length) map { x: Int => + data = List.range(0, length) map { x: Int => if ((bitmap & (1 << x)) != 0) BigInt(x+16) else BigInt(x) }) diff --git a/test/files/run/repl-suppressed-warnings.check b/test/files/run/repl-suppressed-warnings.check index 0c449f348c..a8ab9296c0 100644 --- a/test/files/run/repl-suppressed-warnings.check +++ b/test/files/run/repl-suppressed-warnings.check @@ -30,12 +30,18 @@ scala> object o { } } case class DingDangDoobie(ding: Int, dang: Int, doobie: Double) - case class Dongoo ; case class Heyooooo ; for (x <- 1 to 10 ; val y = x ; z = y) yield x + case class Dongoo + @serializable case class Heyooooo + + @deprecated("I'm an ironic deprecation warning") def f0 = 5 // where's this disappearing? + def f1 = scala.Math.Pi // and this? } -warning: there were 4 deprecation warnings; re-run with -deprecation for details +warning: there were 6 deprecation warnings; re-run with -deprecation for details warning: there were 3 unchecked warnings; re-run with -unchecked for details defined module o +scala> + scala> :warnings :3: warning: case classes without a parameter list have been deprecated; use either case objects or case classes with `()' as parameter list. @@ -43,15 +49,16 @@ use either case objects or case classes with `()' as parameter list. ^ :11: warning: case classes without a parameter list have been deprecated; use either case objects or case classes with `()' as parameter list. - case class Dongoo ; case class Heyooooo ; for (x <- 1 to 10 ; val y = x ; z = y) yield x - ^ + case class Dongoo + ^ :11: warning: case classes without a parameter list have been deprecated; use either case objects or case classes with `()' as parameter list. - case class Dongoo ; case class Heyooooo ; for (x <- 1 to 10 ; val y = x ; z = y) yield x - ^ -:11: warning: for comprehension assignment without a `val' declaration is deprecated. - case class Dongoo ; case class Heyooooo ; for (x <- 1 to 10 ; val y = x ; z = y) yield x - ^ + case class Dongoo + ^ +:12: warning: case classes without a parameter list have been deprecated; +use either case objects or case classes with `()' as parameter list. + @serializable case class Heyooooo + ^ scala> diff --git a/test/files/run/repl-suppressed-warnings.scala b/test/files/run/repl-suppressed-warnings.scala index 5ecc16f34c..2d96a8eb24 100644 --- a/test/files/run/repl-suppressed-warnings.scala +++ b/test/files/run/repl-suppressed-warnings.scala @@ -19,8 +19,13 @@ object o { } } case class DingDangDoobie(ding: Int, dang: Int, doobie: Double) - case class Dongoo ; case class Heyooooo ; for (x <- 1 to 10 ; val y = x ; z = y) yield x + case class Dongoo + @serializable case class Heyooooo + + @deprecated("I'm an ironic deprecation warning") def f0 = 5 // where's this disappearing? + def f1 = scala.Math.Pi // and this? } + :warnings """ } diff --git a/test/files/run/sequenceComparisons.scala b/test/files/run/sequenceComparisons.scala index 2b5833aacc..c2f7ddc697 100644 --- a/test/files/run/sequenceComparisons.scala +++ b/test/files/run/sequenceComparisons.scala @@ -104,10 +104,10 @@ object Test { val scrut = s1f(seq) for (Method(f, (trueList, falseList), descr) <- methodList) { - for (s <- trueList; val rhs = s2f(s)) + for (s <- trueList; rhs = s2f(s)) assertOne(scrut, rhs, f(scrut, rhs), descr) - for (s <- falseList; val rhs = s2f(s)) + for (s <- falseList; rhs = s2f(s)) assertOne(scrut, rhs, !f(scrut, rhs), "!(" + descr + ")") } } diff --git a/test/files/run/t1939.scala b/test/files/run/t1939.scala index 5a36348761..7626e8bc1a 100644 --- a/test/files/run/t1939.scala +++ b/test/files/run/t1939.scala @@ -25,7 +25,7 @@ object Test extends App { def f(ts: List[tType]): Unit = { - for (t <- ts; val m = t.module) {} + for (t <- ts; m = t.module) {} ts.map(t => t.module).foreach { _ => () } // ts.map(t => (t : T).module).foreach { _ => () } // runs successfully } -- cgit v1.2.3