summaryrefslogtreecommitdiff
path: root/sources/scalac/ast/TreeGen.java
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-10-10 16:21:10 +0000
committerpaltherr <paltherr@epfl.ch>2003-10-10 16:21:10 +0000
commit5dc0be399082e85cf61fa9956f71478ccf6ddf9e (patch)
treed26b17d67b71ad1f12d223760bb320f8587094b9 /sources/scalac/ast/TreeGen.java
parent2bb320eee9ca370c34c1195055b19283230ffe42 (diff)
downloadscala-5dc0be399082e85cf61fa9956f71478ccf6ddf9e.tar.gz
scala-5dc0be399082e85cf61fa9956f71478ccf6ddf9e.tar.bz2
scala-5dc0be399082e85cf61fa9956f71478ccf6ddf9e.zip
- Fixed length computation in flatten
Diffstat (limited to 'sources/scalac/ast/TreeGen.java')
-rw-r--r--sources/scalac/ast/TreeGen.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java
index 2e0e339470..f8fe7bd488 100644
--- a/sources/scalac/ast/TreeGen.java
+++ b/sources/scalac/ast/TreeGen.java
@@ -531,7 +531,7 @@ public class TreeGen implements Kinds, Modifiers, TypeTags {
/** Flattens the given tree array by inlining Block nodes. */
public Tree[] flatten(Tree[] trees) {
boolean copy = false;
- int length = trees.length;
+ int length = 0;
for (int i = 0; i < trees.length; i++) {
switch (trees[i]) {
case Empty:
@@ -539,11 +539,12 @@ public class TreeGen implements Kinds, Modifiers, TypeTags {
length -= 1;
continue;
case Block(Tree[] stats):
- if (stats.length == 0) continue; // preserve unit literals
+ if (stats.length == 0) break; // preserve unit literals
copy = true;
length += stats.length;
continue;
}
+ length += 1;
}
if (!copy) return trees;
Tree[] clone = new Tree[length];