diff options
author | Martin Odersky <odersky@gmail.com> | 2003-03-14 11:56:02 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2003-03-14 11:56:02 +0000 |
commit | f4a43858e8629180a3ccbae1202514266ea6db07 (patch) | |
tree | 50bc2efb7078f006f16cada03c0ef438c2cbece0 | |
parent | 1a44c882dc8807567058c00d35f9175a7484c640 (diff) | |
download | scala-f4a43858e8629180a3ccbae1202514266ea6db07.tar.gz scala-f4a43858e8629180a3ccbae1202514266ea6db07.tar.bz2 scala-f4a43858e8629180a3ccbae1202514266ea6db07.zip |
*** empty log message ***
-rw-r--r-- | sources/scalac/ast/parser/Parser.java | 24 | ||||
-rw-r--r-- | sources/scalac/typechecker/Analyzer.java | 19 | ||||
-rw-r--r-- | sources/scalac/typechecker/Infer.java | 1 | ||||
-rw-r--r-- | test/files/neg/altherr1.scala | 7 | ||||
-rw-r--r-- | test/files/neg/altherr2.scala | 7 | ||||
-rw-r--r-- | test/neg/altherr1.scala | 7 | ||||
-rw-r--r-- | test/neg/altherr2.scala | 7 |
7 files changed, 60 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) { diff --git a/test/files/neg/altherr1.scala b/test/files/neg/altherr1.scala new file mode 100644 index 0000000000..69443bfd06 --- /dev/null +++ b/test/files/neg/altherr1.scala @@ -0,0 +1,7 @@ +case class Foo[a](); + +module Bug { + def foo[a](): Foo[a] = foo[a](); + foo() match { case _ => 0 } +} + diff --git a/test/files/neg/altherr2.scala b/test/files/neg/altherr2.scala new file mode 100644 index 0000000000..41bcffca36 --- /dev/null +++ b/test/files/neg/altherr2.scala @@ -0,0 +1,7 @@ +trait Foo[a]; + +module Bug { + def foo[a](): Foo[a] = foo[a](); + foo()[Int]; +} + diff --git a/test/neg/altherr1.scala b/test/neg/altherr1.scala new file mode 100644 index 0000000000..69443bfd06 --- /dev/null +++ b/test/neg/altherr1.scala @@ -0,0 +1,7 @@ +case class Foo[a](); + +module Bug { + def foo[a](): Foo[a] = foo[a](); + foo() match { case _ => 0 } +} + diff --git a/test/neg/altherr2.scala b/test/neg/altherr2.scala new file mode 100644 index 0000000000..41bcffca36 --- /dev/null +++ b/test/neg/altherr2.scala @@ -0,0 +1,7 @@ +trait Foo[a]; + +module Bug { + def foo[a](): Foo[a] = foo[a](); + foo()[Int]; +} + |