summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2003-03-14 11:56:02 +0000
committerMartin Odersky <odersky@gmail.com>2003-03-14 11:56:02 +0000
commitf4a43858e8629180a3ccbae1202514266ea6db07 (patch)
tree50bc2efb7078f006f16cada03c0ef438c2cbece0 /sources
parent1a44c882dc8807567058c00d35f9175a7484c640 (diff)
downloadscala-f4a43858e8629180a3ccbae1202514266ea6db07.tar.gz
scala-f4a43858e8629180a3ccbae1202514266ea6db07.tar.bz2
scala-f4a43858e8629180a3ccbae1202514266ea6db07.zip
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r--sources/scalac/ast/parser/Parser.java24
-rw-r--r--sources/scalac/typechecker/Analyzer.java19
-rw-r--r--sources/scalac/typechecker/Infer.java1
3 files changed, 32 insertions, 12 deletions
diff --git a/sources/scalac/ast/parser/Parser.java b/sources/scalac/ast/parser/Parser.java
index 45ce77899e..48c9689901 100644
--- a/sources/scalac/ast/parser/Parser.java
+++ b/sources/scalac/ast/parser/Parser.java
@@ -762,17 +762,18 @@ public class Parser implements Tokens {
return t;
}
- /* SimpleExpr ::= literal
+ /* SimpleExpr ::= SimpleExpr1
+ * | SimpleExpr ArgumentExprs
+ * | new Template
+ * | BlockExpr
+ * | `(' [Expr] `)'
+ *
+ * SimpleExpr1 ::= literal
* | null
* | StableRef
* | super `.' Id
* | SimpleExpr `.' Id
- * | `(' [Expr] `)'
- * | BlockExpr
- * | SimpleExpr `@' TypeArgs
- * | SimpleExpr ArgumentExprs
- * | new Template
- * | `_'
+ * | SimpleExpr TypeArgs
*/
Tree simpleExpr() {
Tree t;
@@ -835,7 +836,14 @@ public class Parser implements Tokens {
t = make.Select(s.skipToken(), t, ident());
break;
case LBRACKET:
- t = make.TypeApply(s.pos, t, typeArgs());
+ switch (t) {
+ case Ident(_):
+ case Select(_, _):
+ t = make.TypeApply(s.pos, t, typeArgs());
+ break;
+ default:
+ return t;
+ }
break;
case LPAREN:
case LBRACE:
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java
index 37d27a1995..44059d4066 100644
--- a/sources/scalac/typechecker/Analyzer.java
+++ b/sources/scalac/typechecker/Analyzer.java
@@ -1350,13 +1350,24 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
// handle the case of application of match to a visitor specially
if (args.length == 1 && args[0] instanceof Visitor) {
Type pattp = matchQualType(fn1);
+ switch (fn1.type) {
+ case PolyType(Symbol[] tparams, _):
+ if (pattp.containsSome(tparams)) {
+ if (global.debug) System.out.println(fn1.type + "+" + pattp);//debug
+ pattp = Type.AnyType; // so isFullyDefined fails below.
+ }
+ }
if (pattp == Type.ErrorType) {
return tree.setType(Type.ErrorType);
} else if (pattp != Type.NoType) {
- Tree fn2 = desugarize.postMatch(fn1, context.enclClass.owner);
- Tree arg1 = transformVisitor(args[0], pattp, pt);
- return copy.Apply(tree, fn2, new Tree[]{arg1})
- .setType(arg1.type);
+ if (infer.isFullyDefined(pattp)) {
+ Tree fn2 = desugarize.postMatch(fn1, context.enclClass.owner);
+ Tree arg1 = transformVisitor(args[0], pattp, pt);
+ return copy.Apply(tree, fn2, new Tree[]{arg1})
+ .setType(arg1.type);
+ } else {
+ return error(tree.pos, "expected pattern type of cases could not be determined");
+ }
}
}
diff --git a/sources/scalac/typechecker/Infer.java b/sources/scalac/typechecker/Infer.java
index 7423d0664d..8c550c9687 100644
--- a/sources/scalac/typechecker/Infer.java
+++ b/sources/scalac/typechecker/Infer.java
@@ -214,6 +214,7 @@ public class Infer implements Modifiers, Kinds {
}
}
+
/** Do type arguments `targs' conform to formal parameters `tparams'?
*/
private boolean isWithinBounds(Symbol[] tparams, Type[] targs) {