summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-07-23 18:22:29 +0000
committerMartin Odersky <odersky@gmail.com>2007-07-23 18:22:29 +0000
commit16d3cf1f8f22c04559145b35bb5f6c0aacfb0d8c (patch)
tree75b5420467e9dae2ef88d6a4aca220b0f907fa2f /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
parent2d3a640e0bff8c79f99c070cf33f9ef921642a18 (diff)
downloadscala-16d3cf1f8f22c04559145b35bb5f6c0aacfb0d8c.tar.gz
scala-16d3cf1f8f22c04559145b35bb5f6c0aacfb0d8c.tar.bz2
scala-16d3cf1f8f22c04559145b35bb5f6c0aacfb0d8c.zip
many bug fixes; short syntax for structural types.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 13f19feb24..9fd430187e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -61,6 +61,7 @@ abstract class RefChecks extends InfoTransform {
class RefCheckTransformer(unit: CompilationUnit) extends Transformer {
var localTyper: analyzer.Typer = typer;
+ var currentApplication: Tree = EmptyTree
// Override checking ------------------------------------------------------------
@@ -729,7 +730,17 @@ abstract class RefChecks extends InfoTransform {
}
}
+ def isRepeatedParamArg(tree: Tree) = currentApplication match {
+ case Apply(fn, args) =>
+ !args.isEmpty && (args.last eq tree) &&
+ fn.tpe.paramTypes.length == args.length &&
+ fn.tpe.paramTypes.last.typeSymbol == RepeatedParamClass
+ case _ =>
+ false
+ }
+
val savedLocalTyper = localTyper
+ val savedCurrentApplication = currentApplication
val sym = tree.symbol
var result = tree
tree match {
@@ -775,6 +786,7 @@ abstract class RefChecks extends InfoTransform {
case Apply(fn, args) =>
checkSensible(tree.pos, fn, args)
+ currentApplication = tree
case If(cond, thenpart, elsepart) =>
cond.tpe match {
@@ -787,6 +799,11 @@ abstract class RefChecks extends InfoTransform {
case New(tpt) =>
enterReference(tree.pos, tpt.tpe.typeSymbol)
+ case Typed(expr, tpt @ Ident(name)) if (name == nme.WILDCARD_STAR.toTypeName) =>
+ if (!isRepeatedParamArg(tree))
+ unit.error(tree.pos, "no `: _*' annotation allowed here\n"+
+ "(such annotations are only allowed in arguments to *-parameters)")
+
case Ident(name) =>
if (sym.isSourceMethod && sym.hasFlag(CASE))
result = toConstructor(tree.pos, tree.tpe)
@@ -825,6 +842,7 @@ abstract class RefChecks extends InfoTransform {
case _ =>
}
localTyper = savedLocalTyper
+ currentApplication = savedCurrentApplication
result
} catch {
case ex: TypeError =>