diff options
author | paltherr <paltherr@epfl.ch> | 2003-10-28 12:16:58 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-10-28 12:16:58 +0000 |
commit | e231ecf228161bde8aa4f46e0ef4cc86ecf85520 (patch) | |
tree | 32b7faa6b9679fdd414959eee170b5a1bae5469e /sources | |
parent | 95fb97c1d2e7861a456ad7a036f723603a0e1ac1 (diff) | |
download | scala-e231ecf228161bde8aa4f46e0ef4cc86ecf85520.tar.gz scala-e231ecf228161bde8aa4f46e0ef4cc86ecf85520.tar.bz2 scala-e231ecf228161bde8aa4f46e0ef4cc86ecf85520.zip |
- Renamed defavlt into otherwise
- Added Switch without type
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scalac/ast/TreeGen.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java index 598dd54801..0e4b2c26f5 100644 --- a/sources/scalac/ast/TreeGen.java +++ b/sources/scalac/ast/TreeGen.java @@ -673,19 +673,35 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { /** Builds a Switch node with given components and type. */ public Switch Switch(int pos, Tree test, int[] tags, Tree[] bodies, - Tree defavlt, Type type) + Tree otherwise, Type type) { for (int i = 0; i < bodies.length; i++) assert assertTreeSubTypeOf(bodies[i], type); - assert assertTreeSubTypeOf(defavlt, type); - Switch tree = make.Switch(pos, test, tags, bodies, defavlt); + assert assertTreeSubTypeOf(otherwise, type); + Switch tree = make.Switch(pos, test, tags, bodies, otherwise); tree.setType(type); return tree; } - public Switch Switch(Tree test, int[] tags, Tree[] bodies, Tree defavlt, + public Switch Switch(Tree test, int[] tags, Tree[] bodies, Tree otherwise, Type type) { - return Switch(test.pos, test, tags, bodies, defavlt, type); + return Switch(test.pos, test, tags, bodies, otherwise, type); + } + + /** Builds a Switch node with given components. */ + public Switch Switch(int pos, Tree test, int[] tags, Tree[] bodies, + Tree otherwise) + { + Type[] types = new Type[bodies.length + 1]; + for (int i = 0; i < bodies.length; i++) types[i] = bodies[i].type(); + types[bodies.length] = otherwise.type(); + global.nextPhase(); + Type type = Type.lub(types); + global.prevPhase(); + return Switch(pos, test, tags, bodies, otherwise, type); + } + public Switch Switch(Tree test, int[] tags, Tree[] bodies, Tree otherwise){ + return Switch(test.pos, test, tags, bodies, otherwise); } /** Builds a Return node of given method with given value. */ |