@@ -14,6 +14,7 @@ import Flags._
1414import scala .reflect .generic .PickleFormat ._
1515import collection .mutable .{HashMap , ListBuffer }
1616import annotation .switch
17+ import java .io .IOException
1718
1819/** @author Martin Odersky
1920 * @version 1.0
@@ -58,6 +59,17 @@ abstract class UnPickler extends reflect.generic.UnPickler {
5859 def toTypeError (e : MissingRequirementError ) =
5960 new TypeError (e.msg)
6061
62+ /** Convert to a type error, that is printed gracefully instead of crashing.
63+ *
64+ * Similar in intent to what SymbolLoader does (but here we don't have access to
65+ * error reporting, so we rely on the typechecker to report the error).
66+ *
67+ * @note Unlike 2.10, 2.9 may throw either IOException or MissingRequirementError. This
68+ * simply tries to make it more robust.
69+ */
70+ def toTypeError (e : IOException ) =
71+ new TypeError (e.getMessage)
72+
6173 /** A lazy type which when completed returns type at index `i`. */
6274 private class LazyTypeRef (i : Int ) extends LazyType {
6375 private val definedAtRunId = currentRunId
@@ -69,6 +81,7 @@ abstract class UnPickler extends reflect.generic.UnPickler {
6981 if (currentRunId != definedAtRunId) sym.setInfo(adaptToNewRunMap(tp))
7082 } catch {
7183 case e : MissingRequirementError => throw toTypeError(e)
84+ case e : IOException => throw toTypeError(e)
7285 }
7386 override def load (sym : Symbol ) { complete(sym) }
7487 }
@@ -88,6 +101,7 @@ abstract class UnPickler extends reflect.generic.UnPickler {
88101 sym.asInstanceOf [TermSymbol ].setAlias(alias)
89102 } catch {
90103 case e : MissingRequirementError => throw toTypeError(e)
104+ case e : IOException => throw toTypeError(e)
91105 }
92106 }
93107 }
0 commit comments