summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-03-05 08:12:55 -0800
committerPaul Phillips <paulp@improving.org>2013-03-05 08:12:55 -0800
commit106539a52632e90fe3445e70c8f550d60af11af6 (patch)
tree97a4fdd27e4141651add605c832dab7a07881532 /src/compiler
parent62aa0a4f6f20b014e4a30f8922b975827b7d68e8 (diff)
parent9a82fc05244503c32c1ae66352114573eac379c3 (diff)
downloadscala-106539a52632e90fe3445e70c8f550d60af11af6.tar.gz
scala-106539a52632e90fe3445e70c8f550d60af11af6.tar.bz2
scala-106539a52632e90fe3445e70c8f550d60af11af6.zip
Merge pull request #2195 from vigdorchik/lint_library
Changes around lint
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala14
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala19
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala2
3 files changed, 10 insertions, 25 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index 79d0df5a29..140be0e17b 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -31,18 +31,6 @@ abstract class Pickler extends SubComponent {
def newPhase(prev: Phase): StdPhase = new PicklePhase(prev)
class PicklePhase(prev: Phase) extends StdPhase(prev) {
- override def run() {
- super.run()
- // This is run here rather than after typer because I found
- // some symbols - usually annotations, possibly others - had not
- // yet performed the necessary symbol lookup, leading to
- // spurious claims of unusedness.
- if (settings.lint.value) {
- log("Clearing recorded import selectors.")
- analyzer.clearUnusedImports()
- }
- }
-
def apply(unit: CompilationUnit) {
def pickle(tree: Tree) {
def add(sym: Symbol, pickle: Pickle) = {
@@ -83,8 +71,6 @@ abstract class Pickler extends SubComponent {
}
pickle(unit.body)
- if (settings.lint.value)
- analyzer.warnUnusedImports(unit)
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 26e39d3d1b..3e5a61c673 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -52,20 +52,17 @@ trait Contexts { self: Analyzer =>
private lazy val allImportInfos =
mutable.Map[CompilationUnit, List[ImportInfo]]() withDefaultValue Nil
- def clearUnusedImports() {
- allUsedSelectors.clear()
- allImportInfos.clear()
- }
def warnUnusedImports(unit: CompilationUnit) = {
- val imps = allImportInfos(unit).reverse.distinct
-
- for (imp <- imps) {
- val used = allUsedSelectors(imp)
- def isMask(s: ImportSelector) = s.name != nme.WILDCARD && s.rename == nme.WILDCARD
+ for (imps <- allImportInfos.remove(unit)) {
+ for (imp <- imps.reverse.distinct) {
+ val used = allUsedSelectors(imp)
+ def isMask(s: ImportSelector) = s.name != nme.WILDCARD && s.rename == nme.WILDCARD
- imp.tree.selectors filterNot (s => isMask(s) || used(s)) foreach { sel =>
- unit.warning(imp posOf sel, "Unused import")
+ imp.tree.selectors filterNot (s => isMask(s) || used(s)) foreach { sel =>
+ unit.warning(imp posOf sel, "Unused import")
+ }
}
+ allUsedSelectors --= imps
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
index 71470222bf..98c5e31ffe 100644
--- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
@@ -481,6 +481,8 @@ trait TypeDiagnostics {
}
def apply(unit: CompilationUnit) = {
+ warnUnusedImports(unit)
+
val p = new UnusedPrivates
p traverse unit.body
val unused = p.unusedTerms