summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-12-17 11:03:57 +0000
committerMartin Odersky <odersky@gmail.com>2009-12-17 11:03:57 +0000
commit65bd378795d655679778ce2699f2a3c4f0580235 (patch)
treedae755582397dc1aa37b8bcb1f55737f8f499d5b /src/compiler/scala/tools/nsc/transform/OverridingPairs.scala
parent1a7200a1d20afb60bf5e1eb912e7e31c3156a851 (diff)
downloadscala-65bd378795d655679778ce2699f2a3c4f0580235.tar.gz
scala-65bd378795d655679778ce2699f2a3c4f0580235.tar.bz2
scala-65bd378795d655679778ce2699f2a3c4f0580235.zip
hardening the compiler to avoid exceptions I ob...
hardening the compiler to avoid exceptions I observed when used under Eclipse.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/OverridingPairs.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/OverridingPairs.scala39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala
index 9ccc4a8320..cdbea6fcfe 100644
--- a/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala
+++ b/src/compiler/scala/tools/nsc/transform/OverridingPairs.scala
@@ -104,6 +104,10 @@ abstract class OverridingPairs {
*/
private val index = new HashMap[Symbol, Int]
+ // Note: overridingPairs can be called at odd instances by the Eclipse plugin
+ // Soemtimes symbols are not yet defined and we get missing keys.
+ // The implementation here is hardened so that it does not crash on a missing key.
+
{ var i = 0
for (bc <- base.info.baseClasses) {
index(bc) = i
@@ -126,22 +130,37 @@ abstract class OverridingPairs {
{ for (i <- List.range(0, size))
subParents(i) = new BitSet(size);
for (p <- parents) {
- val pIndex = index(p.typeSymbol)
- for (bc <- p.baseClasses)
- if (p.baseType(bc) =:= self.baseType(bc))
- include(subParents(index(bc)), pIndex)
- else if (settings.debug.value)
- log("SKIPPING "+p+" -> "+p.baseType(bc)+" / "+self.baseType(bc)+" from "+base)
+ index get p.typeSymbol match {
+ case Some(pIndex) =>
+ for (bc <- p.baseClasses)
+ if (p.baseType(bc) =:= self.baseType(bc))
+ index get bc match {
+ case Some(bcIndex) =>
+ include(subParents(bcIndex), pIndex)
+ case None =>
+ }
+ else if (settings.debug.value)
+ log("SKIPPING "+p+" -> "+p.baseType(bc)+" / "+self.baseType(bc)+" from "+base)
+ case None =>
+ }
}
- }
+ }
/** Do `sym1` and `sym2` have a common subclass in `parents`?
* In that case we do not follow their overriding pairs
*/
private def hasCommonParentAsSubclass(sym1: Symbol, sym2: Symbol) = {
- val index1 = index(sym1.owner)
- val index2 = index(sym2.owner)
- intersectionContainsElementLeq(subParents(index1), subParents(index2), index1 min index2)
+ index get sym1.owner match {
+ case Some(index1) =>
+ index get sym2.owner match {
+ case Some(index2) =>
+ intersectionContainsElementLeq(subParents(index1), subParents(index2), index1 min index2)
+ case None =>
+ false
+ }
+ case None =>
+ false
+ }
}
/** The scope entries that have already been visited as overridden