Permalink
Browse files

Refine the message and triggering of MissingRequirementError.

 - To force a failure of the stub, call a new method `failIfStub`
   rather than `info`.
 - Offer a broader range of potential root causes in the
   error message.
  • Loading branch information...
retronym committed Nov 10, 2012
1 parent 0b59b46 commit 86e045e2863b04bf4af4abb5c2ce345bcdae2b80
@@ -1344,6 +1344,9 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
}
}
+ /** Raises a `MissingRequirementError` if this symbol is a `StubSymbol` */
+ def failIfStub() {}
+
/** Initialize the symbol */
final def initialize: this.type = {
if (!isInitialized) info
@@ -3100,6 +3103,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
)
}
trait StubSymbol extends Symbol {
+ override final def failIfStub() = fail(())
protected def missingMessage: String
private def fail[T](alt: T): T = {
// Avoid issuing lots of redundant errors
@@ -1385,7 +1385,11 @@ trait Types extends api.Types { self: SymbolTable =>
/** A class for this-types of the form <sym>.this.type
*/
abstract case class ThisType(sym: Symbol) extends SingletonType with ThisTypeApi {
- assert(sym.isClass, {sym.info; sym}) // call .info to allow StubSymbols to reveal what's missing from the classpath
+ // SI-6640 allow StubSymbols to reveal what's missing from the classpath
+ // before we trip the assertion.
+ sym.failIfStub()
+ assert(sym.isClass, sym)
+
//assert(sym.isClass && !sym.isModuleClass || sym.isRoot, sym)
override def isTrivial: Boolean = sym.isPackageClass
override def isNotNull = true
@@ -20,7 +20,7 @@ import scala.annotation.switch
/** @author Martin Odersky
* @version 1.0
*/
-abstract class UnPickler /*extends scala.reflect.generic.UnPickler*/ {
+abstract class UnPickler {
val global: SymbolTable
import global._
@@ -233,7 +233,11 @@ abstract class UnPickler /*extends scala.reflect.generic.UnPickler*/ {
// (4) Call the mirror's "missing" hook.
adjust(mirrorThatLoaded(owner).missingHook(owner, name)) orElse {
// (5) Create a stub symbol to defer hard failure a little longer.
- val missingMessage = s"A signature in $filename refers to ${name.longString} in ${owner.fullLocationString} which is missing from the classpath."
+ val missingMessage =
+ s"""|A signature in $filename refers to ${name.longString} in ${owner.fullLocationString}
+ |which is not available. It may be completely missing from the current classpath,
+ |or the version on the classpath might be incompatible with the version used when
+ |compiling $filename.""".stripMargin
owner.newStubSymbol(name, missingMessage)
}
}

0 comments on commit 86e045e

Please sign in to comment.