diff options
author | buraq <buraq@epfl.ch> | 2003-06-16 15:32:26 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2003-06-16 15:32:26 +0000 |
commit | 152934349f870e1047d6f49c0a6eb2e495a2b3f1 (patch) | |
tree | 920226a6a2dc17c4c60b9ee92b0ab17869947e91 | |
parent | da838048c9d3d2589763929b0f838444393aa8de (diff) | |
download | scala-152934349f870e1047d6f49c0a6eb2e495a2b3f1.tar.gz scala-152934349f870e1047d6f49c0a6eb2e495a2b3f1.tar.bz2 scala-152934349f870e1047d6f49c0a6eb2e495a2b3f1.zip |
started semantic analysis for patterns
-rw-r--r-- | sources/scalac/typechecker/Analyzer.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java index f4c79f4f94..057180d8d6 100644 --- a/sources/scalac/typechecker/Analyzer.java +++ b/sources/scalac/typechecker/Analyzer.java @@ -1739,6 +1739,31 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { return copy.Block(tree, stats1) .setType(owntype); + case Subsequence(Tree[] trees): + return copy.Subsequence( tree, trees ).setType( pt ); + + case Alternative(Tree[] choices): // todo: sanity check for variables + Tree[] newts = new Tree[ choices.length ]; + for (int i = 0; i < choices.length; i++ ) + newts[ i ] = transform( choices[ i ], this.mode, pt ); + + Type tpe = Type.lub( Tree.typeOf( newts )); + + return copy.Alternative( tree, newts ) + .setType( tpe ); + + case Bind( Name name, Tree body ): + Symbol vble = new TermSymbol(tree.pos, name, context.owner, 0x00000000 ).setType( pt ); + vble = enterInScope( vble ); + //patternVars.put( vble, new Boolean( this.inAlternative )); + //System.out.println("put symbol vble="+vble+" in scope and patternVars."); + + body = transform( body ); + //assert body.type != null; + vble.setType( body.type ); + return copy.Bind( tree, name, body ) + .setSymbol( vble ).setType( body.type ); + case Visitor(Tree.CaseDef[] cases): if (pt.symbol().isSubClass(definitions.PARTIALFUNCTION_CLASS)) { Type pft = pt.baseType(definitions.PARTIALFUNCTION_CLASS); |