diff options
author | Paul Phillips <paulp@improving.org> | 2013-05-07 13:59:05 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-05-07 13:59:05 -0700 |
commit | 9a2f6c75cce22565b994c0b8bd2af8acc6e6f178 (patch) | |
tree | acef270db60b2fe2c8538bfcdbbcc8379b89eb30 /src | |
parent | 65a068f42d6b097db5093e0441ab6fec4e8e331c (diff) | |
parent | a86c7a15d1a58e828b61fc12a8b3d0ef0b2f8061 (diff) | |
download | scala-9a2f6c75cce22565b994c0b8bd2af8acc6e6f178.tar.gz scala-9a2f6c75cce22565b994c0b8bd2af8acc6e6f178.tar.bz2 scala-9a2f6c75cce22565b994c0b8bd2af8acc6e6f178.zip |
Merge pull request #2493 from paulp/pr/null-hardening
Hardening against nulls for deserialization.
Diffstat (limited to 'src')
7 files changed, 16 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index 94fbba8066..16ee40280c 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -38,7 +38,7 @@ trait BasicBlocks { import BBFlags._ - def code = method.code + def code = if (method eq null) NoCode else method.code private final class SuccessorList() { private var successors: List[BasicBlock] = Nil 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 07a4e22c1f..192890a509 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -542,7 +542,8 @@ abstract class CopyPropagation { m.isGetter // abstract getters are still pure, as we 'know' final override def toString() = ( - method.blocks map { b => + if (method eq null) List("<null>") + else method.blocks map { b => "\nIN(%s):\t Bindings: %s".format(b.label, in(b).bindings) + "\nIN(%s):\t Stack: %s".format(b.label, in(b).stack) } diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala index 26b7bc50d8..fecd48ed27 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala @@ -240,7 +240,8 @@ abstract class ReachingDefinitions { findDefs(bb, idx, m, 0) override def toString: String = { - method.code.blocks map { b => + if (method eq null) "<null>" + else method.code.blocks map { b => " entry(%s) = %s\n".format(b, in(b)) + " exit(%s) = %s\n".format(b, out(b)) } mkString ("ReachingDefinitions {\n", "\n", "\n}") diff --git a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala index aaf2c55dcd..bde17b28fc 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala @@ -71,8 +71,10 @@ abstract class ClosureElimination extends SubComponent { def name = phaseName val closser = new ClosureElim - override def apply(c: IClass): Unit = - closser analyzeClass c + override def apply(c: IClass): Unit = { + if (closser ne null) + closser analyzeClass c + } } /** diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala index 1026e95fac..483bff6467 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala @@ -33,7 +33,7 @@ abstract class DeadCodeElimination extends SubComponent { val dce = new DeadCode() override def apply(c: IClass) { - if (settings.Xdce) + if (settings.Xdce && (dce ne null)) dce.analyzeClass(c) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 2ad4ec43f7..f27c15180e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -218,7 +218,10 @@ trait Implicits { case _ => false } override def hashCode = name.## + pre.## + sym.## - override def toString = name + ": " + tpe + override def toString = ( + if (tpeCache eq null) name + ": ?" + else name + ": " + tpe + ) } /** A sentinel indicating no implicit was found */ diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index 874c69f46c..6cffdbc193 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -852,7 +852,8 @@ abstract class UnPickler { private val p = phase override def complete(sym: Symbol) : Unit = try { val tp = at(i, () => readType(sym.isTerm)) // after NMT_TRANSITION, revert `() => readType(sym.isTerm)` to `readType` - enteringPhase(p) (sym setInfo tp) + if (p ne null) + enteringPhase(p) (sym setInfo tp) if (currentRunId != definedAtRunId) sym.setInfo(adaptToNewRunMap(tp)) } |