Skip to content

Commit 106539a

Browse files
committed
Merge pull request scala#2195 from vigdorchik/lint_library
Changes around lint
2 parents 62aa0a4 + 9a82fc0 commit 106539a

File tree

11 files changed

+14
-40
lines changed

11 files changed

+14
-40
lines changed

src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ abstract class Pickler extends SubComponent {
3131
def newPhase(prev: Phase): StdPhase = new PicklePhase(prev)
3232

3333
class PicklePhase(prev: Phase) extends StdPhase(prev) {
34-
override def run() {
35-
super.run()
36-
// This is run here rather than after typer because I found
37-
// some symbols - usually annotations, possibly others - had not
38-
// yet performed the necessary symbol lookup, leading to
39-
// spurious claims of unusedness.
40-
if (settings.lint.value) {
41-
log("Clearing recorded import selectors.")
42-
analyzer.clearUnusedImports()
43-
}
44-
}
45-
4634
def apply(unit: CompilationUnit) {
4735
def pickle(tree: Tree) {
4836
def add(sym: Symbol, pickle: Pickle) = {
@@ -83,8 +71,6 @@ abstract class Pickler extends SubComponent {
8371
}
8472

8573
pickle(unit.body)
86-
if (settings.lint.value)
87-
analyzer.warnUnusedImports(unit)
8874
}
8975
}
9076

src/compiler/scala/tools/nsc/typechecker/Contexts.scala

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,17 @@ trait Contexts { self: Analyzer =>
5252
private lazy val allImportInfos =
5353
mutable.Map[CompilationUnit, List[ImportInfo]]() withDefaultValue Nil
5454

55-
def clearUnusedImports() {
56-
allUsedSelectors.clear()
57-
allImportInfos.clear()
58-
}
5955
def warnUnusedImports(unit: CompilationUnit) = {
60-
val imps = allImportInfos(unit).reverse.distinct
61-
62-
for (imp <- imps) {
63-
val used = allUsedSelectors(imp)
64-
def isMask(s: ImportSelector) = s.name != nme.WILDCARD && s.rename == nme.WILDCARD
56+
for (imps <- allImportInfos.remove(unit)) {
57+
for (imp <- imps.reverse.distinct) {
58+
val used = allUsedSelectors(imp)
59+
def isMask(s: ImportSelector) = s.name != nme.WILDCARD && s.rename == nme.WILDCARD
6560

66-
imp.tree.selectors filterNot (s => isMask(s) || used(s)) foreach { sel =>
67-
unit.warning(imp posOf sel, "Unused import")
61+
imp.tree.selectors filterNot (s => isMask(s) || used(s)) foreach { sel =>
62+
unit.warning(imp posOf sel, "Unused import")
63+
}
6864
}
65+
allUsedSelectors --= imps
6966
}
7067
}
7168

src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ trait TypeDiagnostics {
481481
}
482482

483483
def apply(unit: CompilationUnit) = {
484+
warnUnusedImports(unit)
485+
484486
val p = new UnusedPrivates
485487
p traverse unit.body
486488
val unused = p.unusedTerms

src/library/scala/Boolean.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
package scala
1212

13-
import scala.language.implicitConversions
14-
1513
/** `Boolean` (equivalent to Java's `boolean` primitive type) is a
1614
* subtype of [[scala.AnyVal]]. Instances of `Boolean` are not
1715
* represented by an object in the underlying runtime system.

src/library/scala/Double.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
package scala
1212

13-
import scala.language.implicitConversions
14-
1513
/** `Double`, a 64-bit IEEE-754 floating point number (equivalent to Java's `double` primitive type) is a
1614
* subtype of [[scala.AnyVal]]. Instances of `Double` are not
1715
* represented by an object in the underlying runtime system.

src/library/scala/Unit.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
package scala
1212

13-
import scala.language.implicitConversions
14-
15-
1613
/** `Unit` is a subtype of [[scala.AnyVal]]. There is only one value of type
1714
* `Unit`, `()`, and it is not represented by any object in the underlying
1815
* runtime system. A method with return type `Unit` is analogous to a Java

src/library/scala/collection/LinearSeqOptimized.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ package scala.collection
1010

1111
import mutable.ListBuffer
1212
import immutable.List
13-
import scala.util.control.Breaks._
1413
import scala.annotation.tailrec
1514

1615
/** A template trait for linear sequences of type `LinearSeq[A]` which optimizes

src/library/scala/collection/mutable/HashMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extends AbstractMap[A, B]
9595

9696
def iterator = entriesIterator map {e => (e.key, e.value)}
9797

98-
override def foreach[C](f: ((A, B)) => C): Unit = foreachEntry(e => f(e.key, e.value))
98+
override def foreach[C](f: ((A, B)) => C): Unit = foreachEntry(e => f((e.key, e.value)))
9999

100100
/* Override to avoid tuple allocation in foreach */
101101
override def keySet: scala.collection.Set[A] = new DefaultKeySet {

src/library/scala/collection/parallel/immutable/ParRange.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import scala.collection.immutable.Range
1212
import scala.collection.parallel.Combiner
1313
import scala.collection.parallel.SeqSplitter
1414
import scala.collection.generic.CanCombineFrom
15-
import scala.collection.parallel.IterableSplitter
1615
import scala.collection.Iterator
1716

1817
/** Parallel ranges.

src/library/scala/xml/NamespaceBinding.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ case class NamespaceBinding(prefix: String, uri: String, parent: NamespaceBindin
3838

3939
override def toString(): String = sbToString(buildString(_, TopScope))
4040

41-
private def shadowRedefined: NamespaceBinding = shadowRedefined(TopScope)
42-
4341
private def shadowRedefined(stop: NamespaceBinding): NamespaceBinding = {
4442
def prefixList(x: NamespaceBinding): List[String] =
4543
if ((x == null) || (x eq stop)) Nil

0 commit comments

Comments
 (0)