@@ -50,15 +50,25 @@ abstract class UnPickler extends reflect.generic.UnPickler {
5050 def newLazyTypeRef (i : Int ): LazyType = new LazyTypeRef (i)
5151 def newLazyTypeRefAndAlias (i : Int , j : Int ): LazyType = new LazyTypeRefAndAlias (i, j)
5252
53+ /** Convert to a type error, that is printed gracefully instead of crashing.
54+ *
55+ * Similar in intent to what SymbolLoader does (but here we don't have access to
56+ * error reporting, so we rely on the typechecker to report the error).
57+ */
58+ def toTypeError (e : MissingRequirementError ) =
59+ new TypeError (e.msg)
60+
5361 /** A lazy type which when completed returns type at index `i`. */
5462 private class LazyTypeRef (i : Int ) extends LazyType {
5563 private val definedAtRunId = currentRunId
5664 private val p = phase
57- override def complete (sym : Symbol ) : Unit = {
65+ override def complete (sym : Symbol ) : Unit = try {
5866 val tp = at(i, readType)
5967 if (p != phase) atPhase(p) (sym setInfo tp)
6068 else sym setInfo tp
6169 if (currentRunId != definedAtRunId) sym.setInfo(adaptToNewRunMap(tp))
70+ } catch {
71+ case e : MissingRequirementError => throw toTypeError(e)
6272 }
6373 override def load (sym : Symbol ) { complete(sym) }
6474 }
@@ -67,7 +77,7 @@ abstract class UnPickler extends reflect.generic.UnPickler {
6777 * of completed symbol to symbol at index `j`.
6878 */
6979 private class LazyTypeRefAndAlias (i : Int , j : Int ) extends LazyTypeRef (i) {
70- override def complete (sym : Symbol ) {
80+ override def complete (sym : Symbol ) = try {
7181 super .complete(sym)
7282 var alias = at(j, readSymbol)
7383 if (alias hasFlag OVERLOADED ) {
@@ -76,6 +86,8 @@ abstract class UnPickler extends reflect.generic.UnPickler {
7686 }
7787 }
7888 sym.asInstanceOf [TermSymbol ].setAlias(alias)
89+ } catch {
90+ case e : MissingRequirementError => throw toTypeError(e)
7991 }
8092 }
8193 }
0 commit comments