diff options
author | Paul Phillips <paulp@improving.org> | 2011-12-05 23:10:16 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-12-07 11:45:49 -0800 |
commit | 21773d31c1e15d2eec3cf2c8623d582be0a8e4ca (patch) | |
tree | 1e6c8f2239df1af2fb62b6ae0890dcffd6d24873 /src/compiler | |
parent | 33f3c60ce1931b450053ba4635f7227727aed668 (diff) | |
download | scala-21773d31c1e15d2eec3cf2c8623d582be0a8e4ca.tar.gz scala-21773d31c1e15d2eec3cf2c8623d582be0a8e4ca.tar.bz2 scala-21773d31c1e15d2eec3cf2c8623d582be0a8e4ca.zip |
More warnings eliminations.
Deprecation warnings, unchecked warnings, "that's not the value you
think it is" warnings. Also eliminated a warning by fixing a warning bug.
Diffstat (limited to 'src/compiler')
11 files changed, 32 insertions, 20 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 265261f594..d17747e22a 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -649,7 +649,11 @@ trait Types extends api.Types { self: SymbolTable => } /** Returns all parts of this type which satisfy predicate `p` */ - def filter(p: Type => Boolean): List[Type] = new FilterTypeCollector(p).collect(this).toList + def filter(p: Type => Boolean): List[Type] = new FilterTypeCollector(p) collect this + def withFilter(p: Type => Boolean) = new FilterTypeCollector(p) { + def foreach[U](f: Type => U): Unit = collect(Type.this) foreach f + def map[T](f: Type => T): List[T] = collect(Type.this) map f + } /** Returns optionally first type (in a preorder traversal) which satisfies predicate `p`, * or None if none exists. @@ -4094,9 +4098,13 @@ A type's typeSymbol should never be inspected directly. } /** A map to implement the `filter` method. */ - class FilterTypeCollector(p: Type => Boolean) extends TypeCollector(new ListBuffer[Type]) { + class FilterTypeCollector(p: Type => Boolean) extends TypeCollector[List[Type]](Nil) { + def withFilter(q: Type => Boolean) = new FilterTypeCollector(tp => p(tp) && q(tp)) + + override def collect(tp: Type) = super.collect(tp).reverse + def traverse(tp: Type) { - if (p(tp)) result += tp + if (p(tp)) result ::= tp mapOver(tp) } } diff --git a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala index 9aa3d8a2c3..1a8540c158 100644 --- a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala @@ -46,7 +46,7 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ { } } - class Scan(bytes: Array[Byte], offset: Int, classRoot: Symbol, moduleRoot: Symbol, filename: String) extends PickleBuffer(bytes, offset, -1) { + class Scan(_bytes: Array[Byte], offset: Int, classRoot: Symbol, moduleRoot: Symbol, filename: String) extends PickleBuffer(_bytes, offset, -1) { //println("unpickle " + classRoot + " and " + moduleRoot)//debug protected def debug = settings.debug.value diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 7fea76c7b1..f900859f46 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -22,8 +22,8 @@ import symtab.Flags.{ACCESSOR, PARAMACCESSOR} /** The main class of the presentation compiler in an interactive environment such as an IDE */ -class Global(settings: Settings, reporter: Reporter, projectName: String = "") - extends scala.tools.nsc.Global(settings, reporter) +class Global(settings: Settings, _reporter: Reporter, projectName: String = "") + extends scala.tools.nsc.Global(settings, _reporter) with CompilerControl with RangePositions with ContextTrees diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index d001a0af8b..98345dd01e 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -297,7 +297,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { case nme.toDouble => "toDouble" case _ => return None } - Some(newName, runtimeTest) + Some((newName, runtimeTest)) } def infixTest(name: Name): Option[(String, Tree => Tree)] = { val (newName, runtimeTest) = name match { @@ -322,7 +322,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { case nme.ZAND => ("takeConditionalAnd", testForBoolean) case _ => return None } - Some(newName, runtimeTest) + Some((newName, runtimeTest)) } /** The Tree => Tree function in the return is necessary to prevent the original qual diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 9806857ff2..1a421eb82f 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -421,7 +421,7 @@ abstract class Erasure extends AddInterfaces */ /** The modifier typer which retypes with erased types. */ - class Eraser(context: Context) extends Typer(context) { + class Eraser(_context: Context) extends Typer(_context) { private def safeToRemoveUnbox(cls: Symbol): Boolean = (cls == definitions.NullClass) || isBoxedValueClass(cls) diff --git a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala index 031be21f24..2bed5bffd4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala @@ -69,7 +69,7 @@ abstract class Duplicators extends Analyzer { * tree, except for TypeTrees, are erased prior to type checking. TypeTrees * are fixed by substituting invalid symbols for the new ones. */ - class BodyDuplicator(context: Context) extends Typer(context: Context) { + class BodyDuplicator(_context: Context) extends Typer(_context) { class FixInvalidSyms extends TypeMap { diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 79db9ab000..5b38ddd092 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1311,7 +1311,11 @@ trait Infer { case TypeRef(_, sym, _) if isLocalBinding(sym) => ; case _ => - patternWarning(arg, "non variable type-argument ") + // Want to warn about type arguments, not type parameters. Otherwise we'll + // see warnings about "invisible" types, like: val List(x0) = x1 leading to "non + // variable type-argument A in type pattern List[A]..." + if (!arg.typeSymbol.isTypeParameterOrSkolem) + patternWarning(arg, "non variable type-argument ") } } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 0f57285480..364e887939 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -422,7 +422,7 @@ trait Namers extends MethodSynthesis { * @return the companion object symbol. */ def ensureCompanionObject(cdef: ClassDef, creator: ClassDef => Tree = companionModuleDef(_)): Symbol = { - val m = companionModuleOf(cdef.symbol, context) + val m = companionSymbolOf(cdef.symbol, context) // @luc: not sure why "currentRun.compiles(m)" is needed, things breaks // otherwise. documentation welcome. // @@ -855,7 +855,7 @@ trait Namers extends MethodSynthesis { // @check: this seems to work only if the type completer of the class runs before the one of the // module class: the one from the module class removes the entry from classOfModuleClass (see above). if (clazz.isClass && !clazz.hasModuleFlag) { - val modClass = companionModuleOf(clazz, context).moduleClass + val modClass = companionSymbolOf(clazz, context).moduleClass Namers.this.classOfModuleClass get modClass map { cdefRef => val cdef = cdefRef() @@ -1082,7 +1082,7 @@ trait Namers extends MethodSynthesis { val parentNamer = if (isConstr) { val (cdef, nmr) = moduleNamer.getOrElse { - val module = companionModuleOf(clazz, context) + val module = companionSymbolOf(clazz, context) module.initialize // call type completer (typedTemplate), adds the // module's templateNamer to classAndNamerOfModule classAndNamerOfModule get module match { diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index e4ebe13217..8611fafe52 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -189,7 +189,7 @@ trait NamesDefaults { self: Analyzer => if (pre == NoType) { None } else { - val module = companionModuleOf(baseFun.symbol.owner, context) + val module = companionSymbolOf(baseFun.symbol.owner, context) if (module == NoSymbol) None else { val ref = atPos(pos.focus)(gen.mkAttributedRef(pre, module)) @@ -414,7 +414,7 @@ trait NamesDefaults { self: Analyzer => if (i > 0) { val defGetterName = nme.defaultGetterName(param.owner.name, i) if (param.owner.isConstructor) { - val mod = companionModuleOf(param.owner.owner, context) + val mod = companionSymbolOf(param.owner.owner, context) mod.info.member(defGetterName) } else { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 7671ccbed7..9b03d59216 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1361,7 +1361,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { "you want, you must write the annotation class in Java.") if (!isPastTyper) { for (ann <- clazz.getAnnotation(DeprecatedAttr)) { - val m = companionModuleOf(clazz, context) + val m = companionSymbolOf(clazz, context) if (m != NoSymbol) m.moduleClass.addAnnotation(AnnotationInfo(ann.atp, ann.args, List())) } @@ -1377,7 +1377,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { def typedModuleDef(mdef: ModuleDef): Tree = { // initialize all constructors of the linked class: the type completer (Namer.methodSig) // might add default getters to this object. example: "object T; class T(x: Int = 1)" - val linkedClass = companionClassOf(mdef.symbol, context) + val linkedClass = companionSymbolOf(mdef.symbol, context) if (linkedClass != NoSymbol) linkedClass.info.decl(nme.CONSTRUCTOR).alternatives foreach (_.initialize) @@ -2223,7 +2223,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { (methCtx != NoContext) && { val contextFun = methCtx.tree.symbol contextFun.isPrimaryConstructor && contextFun.owner.isModuleClass && - companionModuleOf(calledFun.owner, context).moduleClass == contextFun.owner + companionSymbolOf(calledFun.owner, context).moduleClass == contextFun.owner } } } diff --git a/src/compiler/scala/tools/util/EditDistance.scala b/src/compiler/scala/tools/util/EditDistance.scala index a8d7408532..b705a1eac4 100644 --- a/src/compiler/scala/tools/util/EditDistance.scala +++ b/src/compiler/scala/tools/util/EditDistance.scala @@ -33,7 +33,7 @@ object EditDistance { 0 to n foreach (x => d(x)(0) = x) 0 to m foreach (x => d(0)(x) = x) - for (i <- 1 to n ; val s_i = s(i - 1) ; j <- 1 to m) { + for (i <- 1 to n ; s_i = s(i - 1) ; j <- 1 to m) { val t_j = t(j - 1) val cost = if (s_i == t_j) 0 else 1 |