summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-11-10 21:30:00 +0100
committerJason Zaugg <jzaugg@gmail.com>2012-11-10 23:42:57 +0100
commit86e045e2863b04bf4af4abb5c2ce345bcdae2b80 (patch)
treed307c1f495e4ac3dc5d77a4ff8872a2561acd265
parent0b59b4627a76d99531a51c7f17bbfa8b9c8c4bd8 (diff)
downloadscala-86e045e2863b04bf4af4abb5c2ce345bcdae2b80.tar.gz
scala-86e045e2863b04bf4af4abb5c2ce345bcdae2b80.tar.bz2
scala-86e045e2863b04bf4af4abb5c2ce345bcdae2b80.zip
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.
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala4
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala6
-rw-r--r--src/reflect/scala/reflect/internal/pickling/UnPickler.scala8
3 files changed, 15 insertions, 3 deletions
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index 33d99b35d8..67b2d05224 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -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
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 86d03d7450..57212bab55 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -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
diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
index 15465f919a..5464a68205 100644
--- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
+++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
@@ -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)
}
}