summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2003-12-08 10:55:31 +0000
committerburaq <buraq@epfl.ch>2003-12-08 10:55:31 +0000
commit1f4151cc032d639540a2f4a0ca0639affe52d1ca (patch)
tree92c1fa2dff19be991ce000255dc94bf34b0da05d /sources
parent6e1ccede35b2804295fd38abae6df1b4a06c570c (diff)
downloadscala-1f4151cc032d639540a2f4a0ca0639affe52d1ca.tar.gz
scala-1f4151cc032d639540a2f4a0ca0639affe52d1ca.tar.bz2
scala-1f4151cc032d639540a2f4a0ca0639affe52d1ca.zip
handling of escaped sequences x:_*
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/tools/scalac/typechecker/Analyzer.scala9
-rw-r--r--sources/scalac/typechecker/Analyzer.java19
2 files changed, 28 insertions, 0 deletions
diff --git a/sources/scala/tools/scalac/typechecker/Analyzer.scala b/sources/scala/tools/scalac/typechecker/Analyzer.scala
index b164d54100..0ac50a4358 100644
--- a/sources/scala/tools/scalac/typechecker/Analyzer.scala
+++ b/sources/scala/tools/scalac/typechecker/Analyzer.scala
@@ -2541,6 +2541,15 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
val formals = infer.formalTypes(params, args.length);
var i = 0; while (i < args.length) {
args(i) = adapt(args(i), argMode, formals(i));
+ args(i) match {
+ case Tree$Typed( arg, Tree$Ident( TypeNames.WILDCARD_STAR ) ) =>
+ if( i != args.length - 1 ) {
+ error( arg.pos, "escape only allowed in last position");
+ } else if ( args.length > params.length ) {
+ error( arg.pos, "escaping cannot be mixed with values");
+ }
+ case _ => /* nop */
+ }
i = i + 1
}
return constfold.tryToFold(
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java
index 3457499228..8f7cece248 100644
--- a/sources/scalac/typechecker/Analyzer.java
+++ b/sources/scalac/typechecker/Analyzer.java
@@ -2432,6 +2432,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
// type arguments with formals as prototypes if they exist.
fn1.type = infer.freshInstance(fn1.type);
+
Type[] argtypes = transformArgs(
tree.pos, fn1.symbol(), Symbol.EMPTY_ARRAY, fn1.type, argMode, args, pt);
@@ -2475,11 +2476,20 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
} catch (Type.Error ex) {
reportTypeError(tree.pos, ex);
}
+
switch (fn1.type) {
case MethodType(Symbol[] params, Type restp1):
Type[] formals = infer.formalTypes(params, args.length);
for (int i = 0; i < args.length; i++) {
args[i] = adapt(args[i], argMode, formals[i]);
+ switch( args[ i ] ) {
+ case Typed(Tree arg, Ident(TypeNames.WILDCARD_STAR)):
+ if( i != args.length - 1 ) {
+ error( arg.pos, "escape only allowed in last position");
+ } else if ( args.length > params.length ) {
+ error( arg.pos, "escaping cannot be mixed with values");
+ }
+ }
}
return constfold.tryToFold(
copy.Apply(tree, fn1, args)
@@ -2494,6 +2504,15 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
copy.Apply(tree, fn1, args)
.setType(restp));
}
+
+ // if method signature contains iterated type,
+ // check that possible escaping of sequences happens in the right place
+ if (params.length > 0 &&
+ args.length >= params.length - 1 &&
+ (params[params.length-1].flags & REPEATED) != 0) {
+ System.err.println(" method sign contains iterated type! ");
+ }
+
}
if (fn1.type == Type.ErrorType)