Skip to content

Commit 879e5af

Browse files
committed
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.
1 parent e3e64e4 commit 879e5af

36 files changed

+116
-103
lines changed

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,12 +1640,9 @@ self =>
16401640
val point = in.offset
16411641
val hasEq = in.token == EQUALS
16421642

1643-
if (hasVal && !hasEq)
1644-
syntaxError(in.offset, "val in for comprehension must be followed by assignment")
1645-
if (!hasVal && hasEq) {
1646-
deprecationWarning(in.lastOffset, "for comprehension assignment without a `val' declaration is deprecated.")
1647-
// not yet, deprecated in 2.10.0.
1648-
// syntaxError(in.offset, "assignment in for comprehension must be preceded by `val`")
1643+
if (hasVal) {
1644+
if (hasEq) deprecationWarning(in.offset, "val keyword in for comprehension is deprecated")
1645+
else syntaxError(in.offset, "val in for comprehension must be followed by assignment")
16491646
}
16501647

16511648
if (hasEq && eqOK) in.nextToken()

src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ abstract class TreeBuilder {
318318
*
319319
* 3.
320320
*
321-
* for (P_1 <- G_1; val P_2 <- G_2; ...) ...
321+
* for (P_1 <- G_1; P_2 <- G_2; ...) ...
322322
* ==>
323323
* G_1.flatMap (P_1 => for (P_2 <- G_2; ...) ...)
324324
*
@@ -330,7 +330,7 @@ abstract class TreeBuilder {
330330
*
331331
* 5. For N < MaxTupleArity:
332332
*
333-
* for (P_1 <- G; val P_2 = E_2; val P_N = E_N; ...)
333+
* for (P_1 <- G; P_2 = E_2; val P_N = E_N; ...)
334334
* ==>
335335
* for (TupleN(P_1, P_2, ... P_N) <-
336336
* for (x_1 @ P_1 <- G) yield {

src/compiler/scala/tools/nsc/backend/icode/Members.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ trait Members { self: ICodes =>
224224
val nextBlock: mutable.Map[BasicBlock, BasicBlock] = mutable.HashMap.empty
225225
for (b <- code.blocks.toList
226226
if b.successors.length == 1;
227-
val succ = b.successors.head;
227+
succ = b.successors.head;
228228
if succ ne b;
229229
if succ.predecessors.length == 1;
230230
if succ.predecessors.head eq b;

src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract class Liveness {
4444
gen.clear()
4545
kill.clear()
4646

47-
for (b <- m.code.blocks; val (g, k) = genAndKill(b)) {
47+
for (b <- m.code.blocks; (g, k) = genAndKill(b)) {
4848
gen += (b -> g)
4949
kill += (b -> k)
5050
}

src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ abstract class ReachingDefinitions {
8181
drops.clear()
8282
outStack.clear()
8383

84-
for (b <- m.code.blocks.toList; val (g, k) = genAndKill(b); val (d, st) = dropsAndGen(b)) {
84+
for (b <- m.code.blocks.toList; (g, k) = genAndKill(b); (d, st) = dropsAndGen(b)) {
8585
gen += (b -> g)
8686
kill += (b -> k)
8787
drops += (b -> d)

src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,15 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
421421
c.cunit.source.toString)
422422

423423
var fieldList = List[String]()
424-
for (f <- clasz.fields if f.symbol.hasGetter;
425-
val g = f.symbol.getter(c.symbol);
426-
val s = f.symbol.setter(c.symbol);
427-
if g.isPublic && !(f.symbol.name startsWith "$")) // inserting $outer breaks the bean
424+
for {
425+
f <- clasz.fields
426+
if f.symbol.hasGetter
427+
g = f.symbol.getter(c.symbol)
428+
s = f.symbol.setter(c.symbol)
429+
if g.isPublic && !(f.symbol.name startsWith "$") // inserting $outer breaks the bean
430+
} {
428431
fieldList = javaName(f.symbol) :: javaName(g) :: (if (s != NoSymbol) javaName(s) else null) :: fieldList
432+
}
429433
val methodList =
430434
for (m <- clasz.methods
431435
if !m.symbol.isConstructor &&

src/compiler/scala/tools/nsc/interactive/RefinedBuildManager.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class RefinedBuildManager(val settings: Settings) extends Changes with BuildMana
330330

331331
/** Update the map of definitions per source file */
332332
private def updateDefinitions(files: Set[AbstractFile]) {
333-
for (src <- files; val localDefs = compiler.dependencyAnalysis.definitions(src)) {
333+
for (src <- files; localDefs = compiler.dependencyAnalysis.definitions(src)) {
334334
definitions(src) = (localDefs map (s => {
335335
this.classes += s.fullName -> src
336336
SymWithHistory(

src/compiler/scala/tools/nsc/interpreter/IMain.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,13 +1064,12 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends
10641064
for {
10651065
tpe <- typeOfTerm(id)
10661066
clazz <- classOfTerm(id)
1067-
val staticSym = tpe.typeSymbol
1067+
staticSym = tpe.typeSymbol
10681068
runtimeSym <- safeClass(clazz.getName)
10691069
if runtimeSym != staticSym
10701070
if runtimeSym isSubClass staticSym
1071-
} yield {
1072-
runtimeSym.info
10731071
}
1072+
yield runtimeSym.info
10741073
}
10751074

10761075
object replTokens extends {

src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ abstract class SymbolLoaders {
251251
}
252252
}
253253
// enter decls of parent classes
254-
for (pt <- module.info.parents; val p = pt.typeSymbol) {
254+
for (pt <- module.info.parents; p = pt.typeSymbol) {
255255
if (p != definitions.ObjectClass && p != definitions.ScalaObjectClass) {
256256
openPackageModule(p)(packageClass)
257257
}

src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ abstract class ClassfileParser {
417417
val parts = name.decode.toString.split(Array('.', '$'))
418418
var sym: Symbol = definitions.RootClass
419419
atPhase(currentRun.flattenPhase.prev) {
420-
for (part0 <- parts; if !(part0 == ""); val part = newTermName(part0)) {
420+
for (part0 <- parts; if !(part0 == ""); part = newTermName(part0)) {
421421
val sym1 = atPhase(currentRun.icodePhase) {
422422
sym.linkedClassOfClass.info
423423
sym.info.decl(part.encode)

0 commit comments

Comments
 (0)