summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala8
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala12
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala2
-rw-r--r--src/library/scala/Responder.scala5
-rw-r--r--src/scalacheck/org/scalacheck/Arbitrary.scala2
-rw-r--r--src/scalacheck/org/scalacheck/Gen.scala2
-rw-r--r--src/scalacheck/org/scalacheck/Pretty.scala2
-rw-r--r--test/files/jvm/protectedacc.scala2
-rw-r--r--test/files/jvm/xmlstuff.scala2
-rw-r--r--test/files/neg/for-comprehension-old.check25
-rw-r--r--test/files/neg/for-comprehension-old.scala11
-rw-r--r--test/files/neg/t4163.check4
-rw-r--r--test/files/neg/t4163.scala2
-rw-r--r--test/files/pos/bug0029.scala2
-rw-r--r--test/files/pos/t2413/TestScalac.scala2
-rw-r--r--test/files/run/Course-2002-08.scala12
-rw-r--r--test/files/run/Course-2002-13.scala11
-rw-r--r--test/files/run/bug1192.scala2
-rw-r--r--test/files/run/forvaleq.scala14
-rw-r--r--test/files/run/lazy-leaks.scala2
-rw-r--r--test/files/run/mapConserve.scala2
-rw-r--r--test/files/run/t1939.scala2
24 files changed, 82 insertions, 50 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index 81962f89d8..4a2d8e9f08 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -5645,7 +5645,7 @@ A type's typeSymbol should never be inspected directly.
try {
globalGlbDepth += 1
val dss = ts flatMap refinedToDecls
- for (ds <- dss; val sym <- ds.iterator)
+ for (ds <- dss; sym <- ds.iterator)
if (globalGlbDepth < globalGlbLimit && !(glbThisType specializes sym))
try {
addMember(glbThisType, glbRefined, glbsym(sym))
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
index 97da13abfc..a82e81b858 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
@@ -34,7 +34,6 @@ abstract class Liveness {
final class LivenessAnalysis extends DataFlowAnalysis[livenessLattice.type] {
type P = BasicBlock
val lattice = livenessLattice
-
var method: IMethod = _
val gen: mutable.Map[BasicBlock, Set[Local]] = perRunCaches.newMap()
@@ -42,11 +41,10 @@ abstract class Liveness {
def init(m: IMethod) {
this.method = m
- gen.clear
- kill.clear
+ gen.clear()
+ kill.clear()
- for (b <- m.code.blocks;
- (g, k) = genAndKill(b)) {
+ for (b <- m.code.blocks; val (g, k) = genAndKill(b)) {
gen += (b -> g)
kill += (b -> k)
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala
index cc4619c68f..09718947f4 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala
@@ -75,12 +75,13 @@ abstract class ReachingDefinitions {
def init(m: IMethod) {
this.method = m
- gen.clear; kill.clear
- drops.clear; outStack.clear
- for (b <- m.code.blocks.toList;
- (g, k) = genAndKill(b);
- (d, st) = dropsAndGen(b)) {
+ gen.clear()
+ kill.clear()
+ drops.clear()
+ outStack.clear()
+
+ for (b <- m.code.blocks.toList; val (g, k) = genAndKill(b); val (d, st) = dropsAndGen(b)) {
gen += (b -> g)
kill += (b -> k)
drops += (b -> d)
@@ -96,7 +97,6 @@ abstract class ReachingDefinitions {
m.exh foreach { e =>
in(e.startBlock) = lattice.IState(new ListSet[Definition], List(new ListSet[(BasicBlock, Int)]))
}
-
}
}
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index d43dfdd3d9..81d7e8b373 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -856,7 +856,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
*/
def addCheckedGetters(clazz: Symbol, stats: List[Tree]): List[Tree] = {
- val stats1 = for (stat <- stats; sym = stat.symbol) yield stat match {
+ val stats1 = for (stat <- stats; val sym = stat.symbol) yield stat match {
case DefDef(mods, name, tp, vp, tpt, rhs)
if sym.isLazy && rhs != EmptyTree && !clazz.isImplClass =>
assert(fieldOffset.isDefinedAt(sym))
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index 35a736d34e..f4a7ad678a 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -1512,7 +1512,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
val (oldtparams, newtparams) = reskolemize(tparams)
// create fresh symbols for value parameters to hold the skolem types
- val vparamss1 = List(for (vdef <- vparamss.head; param = vdef.symbol) yield {
+ val vparamss1 = List(for (vdef <- vparamss.head; val param = vdef.symbol) yield {
ValDef(param.cloneSymbol(symbol).setInfo(param.info.substSym(oldtparams, newtparams)))
})
diff --git a/src/library/scala/Responder.scala b/src/library/scala/Responder.scala
index 919ba130d4..189d75a4ae 100644
--- a/src/library/scala/Responder.scala
+++ b/src/library/scala/Responder.scala
@@ -46,12 +46,11 @@ object Responder {
}
def loop[A](r: Responder[Unit]): Responder[Nothing] =
- for (_ <- r; val y <- loop(r)) yield y
+ for (_ <- r; y <- loop(r)) yield y
def loopWhile[A](cond: => Boolean)(r: Responder[Unit]): Responder[Unit] =
- if (cond) for (_ <- r; val y <- loopWhile(cond)(r)) yield y
+ if (cond) for (_ <- r; y <- loopWhile(cond)(r)) yield y
else constant(())
-
}
/** Instances of responder are the building blocks of small programs
diff --git a/src/scalacheck/org/scalacheck/Arbitrary.scala b/src/scalacheck/org/scalacheck/Arbitrary.scala
index 91d56b0aec..608b3b9fac 100644
--- a/src/scalacheck/org/scalacheck/Arbitrary.scala
+++ b/src/scalacheck/org/scalacheck/Arbitrary.scala
@@ -143,7 +143,7 @@ object Arbitrary {
/** Arbitrary instance of Date */
implicit lazy val arbDate: Arbitrary[Date] = Arbitrary(for {
l <- arbitrary[Long]
- d = new Date
+ val d = new Date
} yield new Date(d.getTime + l))
/** Arbitrary instance of Throwable */
diff --git a/src/scalacheck/org/scalacheck/Gen.scala b/src/scalacheck/org/scalacheck/Gen.scala
index a253b040cd..f1bf3c87de 100644
--- a/src/scalacheck/org/scalacheck/Gen.scala
+++ b/src/scalacheck/org/scalacheck/Gen.scala
@@ -399,7 +399,7 @@ object Gen {
/** A generator that picks a given number of elements from a list, randomly */
def pick[T](n: Int, g1: Gen[T], g2: Gen[T], gs: Gen[T]*): Gen[Seq[T]] = for {
is <- pick(n, 0 until (gs.size+2))
- allGs = gs ++ (g1::g2::Nil)
+ val allGs = gs ++ (g1::g2::Nil)
xs <- sequence[List,T](is.toList.map(allGs(_)))
} yield xs
diff --git a/src/scalacheck/org/scalacheck/Pretty.scala b/src/scalacheck/org/scalacheck/Pretty.scala
index f59ac315c7..9e215c4cb7 100644
--- a/src/scalacheck/org/scalacheck/Pretty.scala
+++ b/src/scalacheck/org/scalacheck/Pretty.scala
@@ -86,7 +86,7 @@ object Pretty {
"> Collected test data: " / {
for {
(xs,r) <- fm.getRatios
- ys = xs - ()
+ val ys = xs - ()
if !ys.isEmpty
} yield round(r*100)+"% " + ys.mkString(", ")
}.mkString("\n")
diff --git a/test/files/jvm/protectedacc.scala b/test/files/jvm/protectedacc.scala
index c3b07a0a7e..89e70b90d8 100644
--- a/test/files/jvm/protectedacc.scala
+++ b/test/files/jvm/protectedacc.scala
@@ -82,7 +82,7 @@ package p {
Console.println("meth1(1) = " + meth1(1));
Console.println("meth1(1.0) = " + meth1(1.0));
// test accesses from closures
- for (val x <- 1 until 3)
+ for (x <- 1 until 3)
Console.println("meth2(1)(1) = " + meth2(1)("prefix: "));
Console.println("meth3 = " + meth3.getClass);
diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala
index 08aa716352..f2ad0307b1 100644
--- a/test/files/jvm/xmlstuff.scala
+++ b/test/files/jvm/xmlstuff.scala
@@ -27,7 +27,7 @@ object Test {
<bar value="5" gi='go'/>
</foo>;
- val pelems_1 = for( val x <- p \ "bar"; val y <- p \ "baz" ) yield {
+ val pelems_1 = for (x <- p \ "bar"; y <- p \ "baz" ) yield {
Text(x.attributes("value").toString + y.attributes("bazValue").toString+ "!")
};
val pelems_2 = new NodeSeq { val theSeq = List(Text("38!"),Text("58!")) };
diff --git a/test/files/neg/for-comprehension-old.check b/test/files/neg/for-comprehension-old.check
new file mode 100644
index 0000000000..ec54d619b4
--- /dev/null
+++ b/test/files/neg/for-comprehension-old.check
@@ -0,0 +1,25 @@
+for-comprehension-old.scala:2: error: assignment in for comprehension must be preceded by `val`
+ for (x <- 1 to 5 ; 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
+ ^
+for-comprehension-old.scala:4: error: assignment in for comprehension must be preceded by `val`
+ for (val x <- 1 to 5 ; y = x) yield x+y // fail
+ ^
+for-comprehension-old.scala:5: error: val in for comprehension must be followed by assignment
+ for (val x <- 1 to 5 ; val y = x) yield x+y // fail
+ ^
+for-comprehension-old.scala:7: error: assignment in for comprehension must be preceded by `val`
+ for (z <- 1 to 2 ; x <- 1 to 5 ; y = x) yield x+y // fail
+ ^
+for-comprehension-old.scala:9: error: val in for comprehension must be followed by assignment
+ for (z <- 1 to 2 ; val x <- 1 to 5 ; y = x) yield x+y // fail
+ ^
+for-comprehension-old.scala:9: error: assignment in for comprehension must be preceded by `val`
+ for (z <- 1 to 2 ; val x <- 1 to 5 ; y = x) yield x+y // fail
+ ^
+for-comprehension-old.scala:10: error: val in for comprehension must be followed by assignment
+ for (z <- 1 to 2 ; val x <- 1 to 5 ; val y = x) yield x+y // fail
+ ^
+8 errors found
diff --git a/test/files/neg/for-comprehension-old.scala b/test/files/neg/for-comprehension-old.scala
new file mode 100644
index 0000000000..476e99808e
--- /dev/null
+++ b/test/files/neg/for-comprehension-old.scala
@@ -0,0 +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 (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 ; 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 d275117833..e94c4fae7c 100644
--- a/test/files/neg/t4163.check
+++ b/test/files/neg/t4163.check
@@ -1,6 +1,6 @@
t4163.scala:4: error: '<-' expected but '=' found.
- x = 3
- ^
+ val x = 3
+ ^
t4163.scala:5: error: illegal start of simple expression
y <- 0 to 100
^
diff --git a/test/files/neg/t4163.scala b/test/files/neg/t4163.scala
index 25ce5522a4..bb4c65f18d 100644
--- a/test/files/neg/t4163.scala
+++ b/test/files/neg/t4163.scala
@@ -1,7 +1,7 @@
class Bug {
val z = (
for {
- x = 3
+ val x = 3
y <- 0 to 100
} yield y
).toArray
diff --git a/test/files/pos/bug0029.scala b/test/files/pos/bug0029.scala
index 0af45ab62d..937b6d70c0 100644
--- a/test/files/pos/bug0029.scala
+++ b/test/files/pos/bug0029.scala
@@ -1,3 +1,3 @@
object Main {
- def f[a]: List[List[a]] = for (val l1 <- Nil; val l2 <- Nil) yield l1
+ def f[a]: List[List[a]] = for (l1 <- Nil; l2 <- Nil) yield l1
}
diff --git a/test/files/pos/t2413/TestScalac.scala b/test/files/pos/t2413/TestScalac.scala
index 098e852dd7..0f395e6c74 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 ; anotherVal = repeatParam("1","2","3"))
+ for (a <- 1 to 4 ; val anotherVal = repeatParam("1","2","3"))
yield anotherVal
}
diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala
index 2e4b5111a9..2423bbc36a 100644
--- a/test/files/run/Course-2002-08.scala
+++ b/test/files/run/Course-2002-08.scala
@@ -135,9 +135,9 @@ object M3 {
object M4 {
def test = {
- for (val i <- range(1, 4)) { Console.print(i + " ") };
+ for (i <- range(1, 4)) { Console.print(i + " ") };
Console.println;
- Console.println(for (val i <- range(1, 4)) yield i);
+ Console.println(for (i <- range(1, 4)) yield i);
Console.println;
}
}
@@ -561,14 +561,14 @@ class Main() extends CircuitSimulator() {
val outNum = 1 << n;
val in = new Wire();
- val ctrl = for (val x <- range(0,n)) yield { new Wire() };
- val out = for (val x <- range(0,outNum)) yield { new Wire() };
+ val ctrl = for (x <- range(0,n)) yield { new Wire() };
+ val out = for (x <- range(0,outNum)) yield { new Wire() };
demux(in, ctrl.reverse, out.reverse);
probe("in", in);
- for (val Pair(x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) }
- for (val Pair(x,o) <- range(0,outNum) zip out) { probe("out" + x, o) }
+ for (Pair(x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) }
+ for (Pair(x,o) <- range(0,outNum) zip out) { probe("out" + x, o) }
in.setSignal(true);
run;
diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala
index c016d41a90..c266af8c32 100644
--- a/test/files/run/Course-2002-13.scala
+++ b/test/files/run/Course-2002-13.scala
@@ -116,7 +116,7 @@ object Programs {
(lhs.tyvars ::: (rhs flatMap (t => t.tyvars))).distinct;
def newInstance = {
var s: Subst = List();
- for (val a <- tyvars) { s = Binding(a, newVar(a)) :: s }
+ for (a <- tyvars) { s = Binding(a, newVar(a)) :: s }
Clause(lhs map s, rhs map (t => t map s))
}
override def toString() =
@@ -141,9 +141,9 @@ object Programs {
if (solve1(qs, s).isEmpty) Stream.cons(s, Stream.empty)
else Stream.empty
case q :: query1 =>
- for (val clause <- list2stream(clauses);
- val s1 <- tryClause(clause.newInstance, q, s);
- val s2 <- solve1(query1, s1)) yield s2
+ for (clause <- list2stream(clauses);
+ s1 <- tryClause(clause.newInstance, q, s);
+ s2 <- solve1(query1, s1)) yield s2
}
def solve1(query: List[Term], s: Subst): Stream[Subst] = {
@@ -154,8 +154,7 @@ object Programs {
def tryClause(c: Clause, q: Term, s: Subst): Stream[Subst] = {
if (debug) Console.println("trying " + c);
- for (val s1 <- option2stream(unify(q, c.lhs, s));
- val s2 <- solve1(c.rhs, s1)) yield s2;
+ for (s1 <- option2stream(unify(q, c.lhs, s)); s2 <- solve1(c.rhs, s1)) yield s2;
}
solve1(query, List())
diff --git a/test/files/run/bug1192.scala b/test/files/run/bug1192.scala
index a32cbf5c98..3222bb0a37 100644
--- a/test/files/run/bug1192.scala
+++ b/test/files/run/bug1192.scala
@@ -1,7 +1,7 @@
object Test extends App {
val v1: Array[Array[Int]] = Array(Array(1, 2), Array(3, 4))
def f[T](w: Array[Array[T]]) {
- for (val r <- w) println(r.deep.toString)
+ for (r <- w) println(r.deep.toString)
}
f(v1)
}
diff --git a/test/files/run/forvaleq.scala b/test/files/run/forvaleq.scala
index 8c1824a769..40dbfd099a 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
- xf = firstDigit(x)
+ val 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
- xf = firstDigit(x)
- yf = x - firstDigit(x) / 10
- (a, b) = (xf - yf, xf + yf)
+ val xf = firstDigit(x)
+ val yf = x - firstDigit(x) / 10
+ val (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
- xf = firstDigit(x)
+ val 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
- xf = firstDigit(x)
+ val 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
- xf = fdct(x)
+ val xf = fdct(x)
if xf % 2 == 1}
yield xf
diff --git a/test/files/run/lazy-leaks.scala b/test/files/run/lazy-leaks.scala
index e3db55aa09..22a3770d07 100644
--- a/test/files/run/lazy-leaks.scala
+++ b/test/files/run/lazy-leaks.scala
@@ -9,7 +9,7 @@ object Test extends App
// This test requires 4 Mb of RAM if Lazy is discarding thunks
// It consumes 4 Gb of RAM if Lazy is not discarding thunks
- for (val idx <- Iterator.range(0, 1024)) {
+ for (idx <- Iterator.range(0, 1024)) {
val data = new Array[Int](1024*1024)
val lz: Lazy = new Lazy(data.length)
buffer += lz
diff --git a/test/files/run/mapConserve.scala b/test/files/run/mapConserve.scala
index a285113b11..176e38bed4 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);
- data = List.range(0, length) map { x: Int =>
+ val 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/t1939.scala b/test/files/run/t1939.scala
index 7626e8bc1a..5a36348761 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; m = t.module) {}
+ for (t <- ts; val m = t.module) {}
ts.map(t => t.module).foreach { _ => () }
// ts.map(t => (t : T).module).foreach { _ => () } // runs successfully
}