diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-07-01 11:54:45 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-07-01 11:54:45 -0700 |
commit | c1451cfca63764bc4096cd87168954db2be3da05 (patch) | |
tree | aae080c86eaaaa09f10b6a968b11052aafdd2832 /src/compiler | |
parent | 5f60f27ab34f59253b7af5251250388ca606019b (diff) | |
parent | b86d29eda5166c6e8033215a1615fdab33a5de40 (diff) | |
download | scala-c1451cfca63764bc4096cd87168954db2be3da05.tar.gz scala-c1451cfca63764bc4096cd87168954db2be3da05.tar.bz2 scala-c1451cfca63764bc4096cd87168954db2be3da05.zip |
Merge pull request #2693 from lexspoon/semmle-lint
Lint-like fixes found by Semmle
Diffstat (limited to 'src/compiler')
9 files changed, 41 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/ant/sabbus/Settings.scala b/src/compiler/scala/tools/ant/sabbus/Settings.scala index d0fefdaa03..4cbc03d8d4 100644 --- a/src/compiler/scala/tools/ant/sabbus/Settings.scala +++ b/src/compiler/scala/tools/ant/sabbus/Settings.scala @@ -93,4 +93,18 @@ class Settings { case _ => false } + override lazy val hashCode: Int = Seq( + gBf, + uncheckedBf, + classpathBf, + sourcepathBf, + sourcedirBf, + bootclasspathBf, + extdirsBf, + dBf, + encodingBf, + targetBf, + optimiseBf, + extraParamsBf + ).## } diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 9b83008bd3..e6f21fc1e3 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1748,7 +1748,7 @@ abstract class GenICode extends SubComponent { /////////////////////// Context //////////////////////////////// - abstract class Cleanup(val value: AnyRef) { + sealed abstract class Cleanup(val value: AnyRef) { def contains(x: AnyRef) = value == x } case class MonitorRelease(m: Local) extends Cleanup(m) { } diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 4389afb2b7..91bd39232e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -108,6 +108,14 @@ trait Members { if (symbol eq other.symbol) 0 else if (symbol isLess other.symbol) -1 else 1 + + override def equals(other: Any): Boolean = + other match { + case other: IMember => (this compare other) == 0 + case _ => false + } + + override def hashCode = symbol.## } /** Represent a class in ICode */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala index 0c3f92f13f..9d48d7a0d3 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -27,7 +27,7 @@ abstract class CopyPropagation { case object This extends Location /** Values that can be on the stack. */ - abstract class Value { } + sealed abstract class Value { } case class Record(cls: Symbol, bindings: mutable.Map[Symbol, Value]) extends Value { } /** The value of some location in memory. */ case class Deref(l: Location) extends Value diff --git a/src/compiler/scala/tools/nsc/dependencies/Changes.scala b/src/compiler/scala/tools/nsc/dependencies/Changes.scala index c341d33a62..81d64421b3 100644 --- a/src/compiler/scala/tools/nsc/dependencies/Changes.scala +++ b/src/compiler/scala/tools/nsc/dependencies/Changes.scala @@ -16,7 +16,7 @@ abstract class Changes { import compiler._ import symtab.Flags._ - abstract class Change + sealed abstract class Change private lazy val annotationsChecked = List(definitions.SpecializedClass) // Any others that should be checked? @@ -38,7 +38,7 @@ abstract class Changes { /** An entity in source code, either a class or a member definition. * Name is fully-qualified. */ - abstract class Entity + sealed abstract class Entity case class Class(name: String) extends Entity case class Definition(name: String) extends Entity diff --git a/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala b/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala index da1cc0c4cf..4f45043c5e 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala @@ -11,7 +11,7 @@ package tools.nsc.settings * Represents a single Scala version in a manner that * supports easy comparison and sorting. */ -abstract class ScalaVersion extends Ordered[ScalaVersion] { +sealed abstract class ScalaVersion extends Ordered[ScalaVersion] { def unparse: String } diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala index bce0a077fb..baccdcf544 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala @@ -79,7 +79,7 @@ trait MatchTreeMaking extends MatchCodeGen with Debugging { def chainBefore(next: Tree)(casegen: Casegen): Tree } - trait NoNewBinders extends TreeMaker { + sealed trait NoNewBinders extends TreeMaker { protected val localSubstitution: Substitution = EmptySubstitution } @@ -105,12 +105,12 @@ trait MatchTreeMaking extends MatchCodeGen with Debugging { override def toString = "S"+ localSubstitution } - abstract class FunTreeMaker extends TreeMaker { + sealed abstract class FunTreeMaker extends TreeMaker { val nextBinder: Symbol def pos = nextBinder.pos } - abstract class CondTreeMaker extends FunTreeMaker { + sealed abstract class CondTreeMaker extends FunTreeMaker { val prevBinder: Symbol val nextBinderTp: Type val cond: Tree @@ -126,7 +126,7 @@ trait MatchTreeMaking extends MatchCodeGen with Debugging { // unless we're optimizing, emit local variable bindings for all subpatterns of extractor/case class patterns protected val debugInfoEmitVars = !settings.optimise.value - trait PreserveSubPatBinders extends TreeMaker { + sealed trait PreserveSubPatBinders extends TreeMaker { val subPatBinders: List[Symbol] val subPatRefs: List[Tree] val ignoredSubPatBinders: Set[Symbol] diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 7fa199afaf..a3ab948171 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -21,13 +21,13 @@ trait ContextErrors { import global._ import definitions._ - abstract class AbsTypeError extends Throwable { + sealed abstract class AbsTypeError extends Throwable { def errPos: Position def errMsg: String override def toString() = "[Type error at:" + errPos + "] " + errMsg } - abstract class TreeTypeError extends AbsTypeError { + sealed abstract class TreeTypeError extends AbsTypeError { def underlyingTree: Tree def errPos = underlyingTree.pos } diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 646bf3a153..546186479f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -259,7 +259,7 @@ trait MethodSynthesis { * So it's important that creating an instance of Derived does not have a side effect, * or if it has a side effect, control that it is done only once. */ - trait Derived { + sealed trait Derived { /** The tree from which we are deriving a synthetic member. Typically, that's * given as an argument of the instance. */ @@ -288,7 +288,7 @@ trait MethodSynthesis { def derivedTree: Tree } - trait DerivedFromMemberDef extends Derived { + sealed trait DerivedFromMemberDef extends Derived { def tree: MemberDef def enclClass: Symbol @@ -297,12 +297,12 @@ trait MethodSynthesis { final def basisSym = tree.symbol } - trait DerivedFromClassDef extends DerivedFromMemberDef { + sealed trait DerivedFromClassDef extends DerivedFromMemberDef { def tree: ClassDef final def enclClass = basisSym.owner.enclClass } - trait DerivedFromValDef extends DerivedFromMemberDef { + sealed trait DerivedFromValDef extends DerivedFromMemberDef { def tree: ValDef final def enclClass = basisSym.enclClass @@ -341,10 +341,10 @@ trait MethodSynthesis { logDerived(derivedTree) } } - trait DerivedGetter extends DerivedFromValDef { + sealed trait DerivedGetter extends DerivedFromValDef { // TODO } - trait DerivedSetter extends DerivedFromValDef { + sealed trait DerivedSetter extends DerivedFromValDef { override def isSetter = true private def setterParam = derivedSym.paramss match { case (p :: Nil) :: _ => p @@ -378,7 +378,7 @@ trait MethodSynthesis { def name: TermName = tree.name.toTermName } - abstract class BaseGetter(tree: ValDef) extends DerivedGetter { + sealed abstract class BaseGetter(tree: ValDef) extends DerivedGetter { def name = tree.name def category = GetterTargetClass def flagsMask = GetterFlags @@ -510,7 +510,7 @@ trait MethodSynthesis { def flagsExtra = 0 override def derivedSym = enclClass.info decl name } - trait AnyBeanGetter extends BeanAccessor with DerivedGetter { + sealed trait AnyBeanGetter extends BeanAccessor with DerivedGetter { def category = BeanGetterTargetClass override def validate() { if (derivedSym == NoSymbol) { |