diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 18 |
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 => |