summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-09-17 11:00:31 +0000
committerMartin Odersky <odersky@gmail.com>2009-09-17 11:00:31 +0000
commit27f573afb47fcc38627df20058fae1cfa0fcb947 (patch)
tree20b3a7d1a1e7a4a4542d4c307bf90a4a2f02ec6b /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent63089db7fb68d070a2fdbcd3ca893a638eb5137e (diff)
downloadscala-27f573afb47fcc38627df20058fae1cfa0fcb947.tar.gz
scala-27f573afb47fcc38627df20058fae1cfa0fcb947.tar.bz2
scala-27f573afb47fcc38627df20058fae1cfa0fcb947.zip
new starr, with some changes to varargs handling.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index d936941224..2d519f8da8 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -397,7 +397,7 @@ trait Typers { self: Analyzer =>
/*
if (formals.exists(_.typeSymbol == ByNameParamClass) && formals.length != 1)
error(pos, "methods with `=>'-parameter can be converted to function values only if they take no other parameters")
- if (formals exists (_.typeSymbol == RepeatedParamClass))
+ if (formals exists (isRepeatedParamType(_)))
error(pos, "methods with `*'-parameters cannot be converted to function values");
*/
if (restpe.isDependent)
@@ -913,7 +913,7 @@ trait Typers { self: Analyzer =>
case _ =>
false
}
- if (isStructuralType(pt) && tree.tpe.typeSymbol == ArrayClass) {
+ if (isStructuralType(pt) && tree.tpe.typeSymbol == ArrayClass && !settings.newArrays.value) {
// all Arrays used as structural refinement typed values must be boxed
// this does not solve the case where the type to be adapted to comes
// from a type variable that was bound by a strctural but is instantiated
@@ -1449,7 +1449,7 @@ trait Typers { self: Analyzer =>
case Apply(fn, args) =>
val (superConstr, args1) = decompose(fn)
val formals = fn.tpe.paramTypes
- val args2 = if (formals.isEmpty || formals.last.typeSymbol != RepeatedParamClass) args
+ val args2 = if (formals.isEmpty || !isRepeatedParamType(formals.last)) args
else args.take(formals.length - 1) ::: List(EmptyTree)
if (args2.length != formals.length)
assert(false, "mismatch " + clazz + " " + formals + " " + args2);//debug
@@ -1522,7 +1522,7 @@ trait Typers { self: Analyzer =>
val tparams1 = ddef.tparams mapConserve typedTypeDef
val vparamss1 = ddef.vparamss mapConserve (_ mapConserve typedValDef)
for (vparams1 <- vparamss1; if !vparams1.isEmpty; vparam1 <- vparams1.init) {
- if (vparam1.symbol.tpe.typeSymbol == RepeatedParamClass)
+ if (isRepeatedParamType(vparam1.symbol.tpe))
error(vparam1.pos, "*-parameter must come last")
}
var tpt1 = checkNoEscaping.privates(meth, typedType(ddef.tpt))
@@ -1577,10 +1577,7 @@ trait Typers { self: Analyzer =>
}
}
- if (meth.paramss.exists( ps => {
- ps.exists(_.hasFlag(DEFAULTPARAM)) &&
- (ps.last.tpe.typeSymbol == RepeatedParamClass)
- }))
+ if (meth.paramss.exists(ps => ps.exists(_.hasFlag(DEFAULTPARAM)) && isRepeatedParamType(ps.last.tpe)))
error(meth.pos, "a parameter section with a `*'-parameter is not allowed to have default arguments")
}
@@ -3660,7 +3657,18 @@ trait Typers { self: Analyzer =>
typed1(atPos(tree.pos)(Block(stats, Apply(expr, args))), mode, pt)
case Apply(fun, args) =>
- typedApply(fun, args)
+ typedApply(fun, args) match {
+ case Apply(Select(New(tpt), name), args)
+ if (settings.newArrays.value && tpt.tpe.typeSymbol == ArrayClass && args.length == 1 && erasure.isTopLevelGenericArray(tpt.tpe)) =>
+ // convert new Array[T](len) to evidence[ClassManifest[T]].newArray(len)
+ val newArrayApp = atPos(tree.pos) {
+ val manif = getManifestTree(tree.pos, tpt.tpe.typeArgs.head, false)
+ Apply(Select(manif, nme.newArray), args)
+ }
+ typed(newArrayApp, mode, pt)
+ case tree1 =>
+ tree1
+ }
case ApplyDynamic(qual, args) =>
val reflectiveCalls = !(settings.refinementMethodDispatch.value == "invoke-dynamic")
@@ -3884,16 +3892,17 @@ trait Typers { self: Analyzer =>
case None => typed(tree, pt)
}
- def findManifest(tp: Type, full: Boolean) =
+ def findManifest(tp: Type, full: Boolean) = atPhase(currentRun.typerPhase) {
inferImplicit(
EmptyTree,
appliedType((if (full) FullManifestClass else PartialManifestClass).typeConstructor, List(tp)),
true, false, context)
+ }
def getManifestTree(pos: Position, tp: Type, full: Boolean): Tree = {
val manifestOpt = findManifest(tp, false)
if (manifestOpt.tree.isEmpty) {
- error(pos, "cannot find "+(if (full) "" else "class ")+"manifest for element type of "+tp)
+ error(pos, "cannot find "+(if (full) "" else "class ")+"manifest for element type "+tp)
Literal(Constant(null))
} else {
manifestOpt.tree