From 86e045e2863b04bf4af4abb5c2ce345bcdae2b80 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 10 Nov 2012 21:30:00 +0100 Subject: 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. --- src/reflect/scala/reflect/internal/Symbols.scala | 4 ++++ src/reflect/scala/reflect/internal/Types.scala | 6 +++++- src/reflect/scala/reflect/internal/pickling/UnPickler.scala | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') 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 .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) } } -- cgit v1.2.3