diff options
author | Paul Phillips <paulp@improving.org> | 2010-11-04 00:07:36 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-11-04 00:07:36 +0000 |
commit | 379af580e2c8cf0ce5309fc0b31702f79e415abe (patch) | |
tree | cf741eb0d27624d6130bb5bc7f403ec7fb05af1d /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | |
parent | de012b3a6d04f1e7a9fd6fecd403e0492f6ad7c1 (diff) | |
download | scala-379af580e2c8cf0ce5309fc0b31702f79e415abe.tar.gz scala-379af580e2c8cf0ce5309fc0b31702f79e415abe.tar.bz2 scala-379af580e2c8cf0ce5309fc0b31702f79e415abe.zip |
Determined that half a dozen ways of checking f...
Determined that half a dozen ways of checking for varargs and
by-name-ness in param lists exceeded the legal limit. Also assessed that
names which are only used as type names would be a lot easier to deal
with if we created them as type names up front. Performed the changes
implied by the preceding along with a partial cleanup on TreeInfo which
one can see hasn't had a good look in a long time. (And still hasn't.)
No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 78341f6046..c49acf3f01 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -81,7 +81,7 @@ abstract class RefChecks extends InfoTransform { val toScalaRepeatedParam = new TypeMap { def apply(tp: Type): Type = tp match { - case tp @ TypeRef(pre, JavaRepeatedParamClass, args) => + case TypeRef(pre, JavaRepeatedParamClass, args) => typeRef(pre, RepeatedParamClass, args) case _ => mapOver(tp) @@ -122,20 +122,15 @@ abstract class RefChecks extends InfoTransform { // Override checking ------------------------------------------------------------ def hasRepeatedParam(tp: Type): Boolean = tp match { - case MethodType(formals, restpe) => - formals.nonEmpty && formals.last.tpe.typeSymbol == RepeatedParamClass || - hasRepeatedParam(restpe) - case PolyType(_, restpe) => - hasRepeatedParam(restpe) - case _ => - false + case MethodType(formals, restpe) => isScalaVarArgs(formals) || hasRepeatedParam(restpe) + case PolyType(_, restpe) => hasRepeatedParam(restpe) + case _ => false } /** Add bridges for vararg methods that extend Java vararg methods */ def addVarargBridges(clazz: Symbol): List[Tree] = { val self = clazz.thisType - val bridges = new ListBuffer[Tree] def varargBridge(member: Symbol, bridgetpe: Type): Tree = { @@ -1343,14 +1338,14 @@ abstract class RefChecks extends InfoTransform { enterReference(tree.pos, tpt.tpe.typeSymbol) tree - case Typed(expr, tpt @ Ident(name)) if name == nme.WILDCARD_STAR.toTypeName && !isRepeatedParamArg(tree) => + case Typed(_, Ident(nme.WILDCARD_STAR)) if !isRepeatedParamArg(tree) => unit.error(tree.pos, "no `: _*' annotation allowed here\n"+ "(such annotations are only allowed in arguments to *-parameters)") tree case Ident(name) => transformCaseApply(tree, - if (name != nme.WILDCARD && name != nme.WILDCARD_STAR.toTypeName) { + if (name != nme.WILDCARD && name != nme.WILDCARD_STAR) { assert(sym != NoSymbol, tree) //debug enterReference(tree.pos, sym) } |