diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2011-11-15 18:03:23 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2011-11-15 18:03:23 +0000 |
commit | ce5d909de942fe16c92963f74be167b0f0c13b08 (patch) | |
tree | 74b374c1e888ea32e3a4e4ad00962a3159d1ec32 | |
parent | 3ba3b39b93b9e8412fd4fe0a7d907a842da2e906 (diff) | |
download | scala-ce5d909de942fe16c92963f74be167b0f0c13b08.tar.gz scala-ce5d909de942fe16c92963f74be167b0f0c13b08.tar.bz2 scala-ce5d909de942fe16c92963f74be167b0f0c13b08.zip |
Made LazyType fail more graciously with incompl...
Made LazyType fail more graciously with incomplete class paths.
SymbolLoaders already do the right thing, printing an error instead of
crashing the compiler. However, the unpickler has two more lazy types
that crash and stop the compiler if, on completion, it encounters a
reference to a missing class file.
Since the SymbolTable has no way of reporting an error, we convert the
MissingRequirementError in TypeErrors. This has the benefit of being
printed nicely by the type checker (with a position where the type was
needed).
This fixes extremely worrying behavior in the IDE when the class path is
incomplete (for instance, after a rebuild with compilation errors).
review by odersky, extempore.
-rw-r--r-- | src/compiler/scala/reflect/internal/pickling/UnPickler.scala | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala index 2280aba54d..7ea5856f09 100644 --- a/src/compiler/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/compiler/scala/reflect/internal/pickling/UnPickler.scala @@ -834,15 +834,20 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ { def newLazyTypeRef(i: Int): LazyType = new LazyTypeRef(i) def newLazyTypeRefAndAlias(i: Int, j: Int): LazyType = new LazyTypeRefAndAlias(i, j) + def toTypeError(e: MissingRequirementError) = + new TypeError(e.msg) + /** A lazy type which when completed returns type at index `i`. */ private class LazyTypeRef(i: Int) extends LazyType { private val definedAtRunId = currentRunId private val p = phase - override def complete(sym: Symbol) : Unit = { + override def complete(sym: Symbol) : Unit = try { val tp = at(i, () => readType(sym.isTerm)) // after NMT_TRANSITION, revert `() => readType(sym.isTerm)` to `readType` if (p != phase) atPhase(p) (sym setInfo tp) else sym setInfo tp if (currentRunId != definedAtRunId) sym.setInfo(adaptToNewRunMap(tp)) + } catch { + case e: MissingRequirementError => throw toTypeError(e) } override def load(sym: Symbol) { complete(sym) } } @@ -851,7 +856,7 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ { * of completed symbol to symbol at index `j`. */ private class LazyTypeRefAndAlias(i: Int, j: Int) extends LazyTypeRef(i) { - override def complete(sym: Symbol) { + override def complete(sym: Symbol) = try { super.complete(sym) var alias = at(j, readSymbol) if (alias.isOverloaded) { @@ -860,6 +865,8 @@ abstract class UnPickler /*extends reflect.generic.UnPickler*/ { } } sym.asInstanceOf[TermSymbol].setAlias(alias) + } catch { + case e: MissingRequirementError => throw toTypeError(e) } } } |