summaryrefslogtreecommitdiff
path: root/sources/scalac/transformer/matching/AlgebraicMatcher.java
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2003-10-01 14:56:25 +0000
committerburaq <buraq@epfl.ch>2003-10-01 14:56:25 +0000
commit64d947d0e2d93ee4c9bc7f6f661cac293f8a9026 (patch)
tree64f09047e9934681fa6a782c6cd36c1a5c55ef14 /sources/scalac/transformer/matching/AlgebraicMatcher.java
parentdd78e43d8f39e994f9fab078dcf53acb9c53faaa (diff)
downloadscala-64d947d0e2d93ee4c9bc7f6f661cac293f8a9026.tar.gz
scala-64d947d0e2d93ee4c9bc7f6f661cac293f8a9026.tar.bz2
scala-64d947d0e2d93ee4c9bc7f6f661cac293f8a9026.zip
fixed bug that appeared with constructors that ...
fixed bug that appeared with constructors that take A* parameters
Diffstat (limited to 'sources/scalac/transformer/matching/AlgebraicMatcher.java')
-rw-r--r--sources/scalac/transformer/matching/AlgebraicMatcher.java31
1 files changed, 27 insertions, 4 deletions
diff --git a/sources/scalac/transformer/matching/AlgebraicMatcher.java b/sources/scalac/transformer/matching/AlgebraicMatcher.java
index ea74702a99..269ecc2e7e 100644
--- a/sources/scalac/transformer/matching/AlgebraicMatcher.java
+++ b/sources/scalac/transformer/matching/AlgebraicMatcher.java
@@ -140,11 +140,17 @@ public class AlgebraicMatcher extends PatternMatcher {
//System.err.println("patternArgs("+tree+")");
switch (tree) {
case Apply(_, Tree[] args):
+ /*
if( isSeqApply( (Apply) tree )) {
//System.err.println("patternArgs: is seq apply !");
return Tree.EMPTY_ARRAY;// let sequence matcher handle this
}
+ if( isStarApply( (Apply) tree )) {
+ return Tree.EMPTY_ARRAY;// let sequence matcher handle this
+
+ }
+ */
return args;
default:
return Tree.EMPTY_ARRAY;
@@ -170,11 +176,18 @@ public class AlgebraicMatcher extends PatternMatcher {
Type castType,
Tree selector,
CaseEnv env) {
+ //System.err.println("patternNode:"+tree );
Type theType = getConstrType( tree.type );
switch (tree) {
case Apply(Tree fn, Tree[] args): // pattern with args
- if( isSeqApply( (Apply) tree ))
- return mk.SeqContainerPat( tree.pos, theType, args[ 0 ] );
+ //System.err.println("Apply, isSeq?" + isSeqApply( (Apply) tree ));
+ //System.err.println("Apply, isStar?" + isStarApply( (Apply) tree ));
+ if( isSeqApply( (Apply) tree )) {
+ PatternNode res = mk.ConstrPat(tree.pos, theType);
+ res.and = mk.Header(tree.pos, castType, selector);
+ res.and.and = mk.SeqContainerPat( tree.pos, theType, args[ 0 ] );
+ return res;
+ }
return mk.ConstrPat(tree.pos, theType);
case Typed(Ident(Name name), Tree tpe): // typed pattern
theType = getConstrType( tpe.type );
@@ -220,7 +233,7 @@ public class AlgebraicMatcher extends PatternMatcher {
return mk.ConstantPat(tree.pos, theType, value);
case Sequence( _ ):
- throw new ApplicationError("Illegal pattern");
+ return mk.SeqContainerPat( tree.pos, theType, tree );
default:
throw new ApplicationError("cannot handle "+tree);
}
@@ -351,7 +364,17 @@ public class AlgebraicMatcher extends PatternMatcher {
boolean isSeqApply( Tree.Apply tree ) {
- return (tree.args.length == 1 && (tree.type.symbol().flags & Modifiers.CASE) == 0);
+ return (tree.args.length == 1 &&
+ (tree.type.symbol().flags & Modifiers.CASE) == 0);
+ }
+
+ boolean isStarApply( Tree.Apply tree ) {
+ Symbol params[] = tree.fun.type.valueParams();
+ //System.err.println( tree.fun.type.resultType().symbol() );
+ return (tree.args.length == 1)
+ && (tree.type.symbol().flags & Modifiers.CASE) != 0
+ && params.length == 1
+ && (params[ 0 ].flags & Modifiers.REPEATED) != 0;
}
//////////// generator methods