diff options
author | paltherr <paltherr@epfl.ch> | 2004-05-17 16:55:50 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2004-05-17 16:55:50 +0000 |
commit | 7432218075b602548bb109fac463077ddc50befd (patch) | |
tree | 3387b4b07fa42cd6a2b837654c6934cd9864fbed /sources | |
parent | 6e8fe0a8c73606122fcfdb9557eaa1ea34d03eb5 (diff) | |
download | scala-7432218075b602548bb109fac463077ddc50befd.tar.gz scala-7432218075b602548bb109fac463077ddc50befd.tar.bz2 scala-7432218075b602548bb109fac463077ddc50befd.zip |
- Fixed optimization/hack in case If and Switch
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scalac/ast/Transformer.java.tmpl | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/sources/scalac/ast/Transformer.java.tmpl b/sources/scalac/ast/Transformer.java.tmpl index d38847dfcd..c13ad02a1d 100644 --- a/sources/scalac/ast/Transformer.java.tmpl +++ b/sources/scalac/ast/Transformer.java.tmpl @@ -222,25 +222,27 @@ public class GenTransformer { cond = transform(cond); thenp = transform(thenp); elsep = transform(elsep); - Type type = tree.type(); - global.nextPhase(); - boolean reuse = type.isSameAs(global.definitions.ANY_TYPE()); - global.prevPhase(); - return reuse - ? gen.If(tree.pos, cond, thenp, elsep, type) - : gen.If(tree.pos, cond, thenp, elsep); + if (tree.type().isSameAs(global.definitions.ANY_TYPE())) { + global.nextPhase(); + Type type = global.definitions.ANY_TYPE(); + global.prevPhase(); + return gen.If(tree.pos, cond, thenp, elsep, type); + } else { + return gen.If(tree.pos, cond, thenp, elsep); + } case Switch(Tree test, int[] tags, Tree[] bodies, Tree otherwise): test = transform(test); bodies = transform(bodies); otherwise = transform(otherwise); - Type type = tree.type(); - global.nextPhase(); - boolean reuse = type.isSameAs(global.definitions.ANY_TYPE()); - global.prevPhase(); - return reuse - ? gen.Switch(tree.pos, test, tags, bodies, otherwise, type) - : gen.Switch(tree.pos, test, tags, bodies, otherwise); + if (tree.type().isSameAs(global.definitions.ANY_TYPE())) { + global.nextPhase(); + Type type = global.definitions.ANY_TYPE(); + global.prevPhase(); + return gen.Switch(tree.pos, test, tags, bodies,otherwise,type); + } else { + return gen.Switch(tree.pos, test, tags, bodies, otherwise); + } case Return(Tree expr): Symbol symbol = getSymbolFor(tree); |