diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-23 20:10:28 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-23 20:12:42 -0800 |
commit | f0e9237834d00ea9e27937e44dc8b8382be32db6 (patch) | |
tree | 9807c35aa0bc818bf487a2c93bd577e37e1adce0 /src/reflect | |
parent | 889ceade520ae5d2d1485edf2826696fa91a0e91 (diff) | |
parent | faa6cfcf404b4d172f20b3ed01ba3bd59427b700 (diff) | |
download | scala-f0e9237834d00ea9e27937e44dc8b8382be32db6.tar.gz scala-f0e9237834d00ea9e27937e44dc8b8382be32db6.tar.bz2 scala-f0e9237834d00ea9e27937e44dc8b8382be32db6.zip |
Merge branch 'merge-2.10.wip-x' into merge-2.10.x-master
* merge-2.10.wip-x: (24 commits)
SI-6023 reify abstract vals
Removing controversial `either` method from Futures API.
SI-6695 Test case for fixed Array match bug
adds comments to standard attachments
SI-6673 fixes macro problems with eta expansions
Restore the opimization apparently lost after merge.
SI-6624 set info of case pattern binder to help find case field accessors
Scaladoc update for collection.mutable.MultiMap
SI-6663: don't ignore type parameter on selectDynamic invocation
SI-6551: don't insert apply call in polymorphic expression.
SI-6634 Fixes data corruption issue in ListBuffer#remove
Fixes SI-6628, Revert "Fix for view isEmpty."
SI-6661 - Remove obsolete implicit parameter of scala.concurrent.promise method
Fixes SI-6150 - backport to 2.10.x branch.
SI-5330, SI-6014 deal with existential self-type
Fixes SI-6559 - StringContext not using passed in escape function.
SI-6648 copyAttrs must preserve TypeTree#wasEmpty
Fix raw string interpolator: string parts which were after the first argument were still escaped
sane printing of renamed imports
SI-6440 Address regressions around MissingRequirementError
...
Conflicts:
src/library/scala/collection/generic/IndexedSeqFactory.scala
src/library/scala/collection/mutable/ListBuffer.scala
src/reflect/scala/reflect/internal/Symbols.scala
src/reflect/scala/reflect/internal/Types.scala
test/files/run/t6150.scala
Diffstat (limited to 'src/reflect')
6 files changed, 67 insertions, 19 deletions
diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 08ba93520a..c36724e388 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -559,8 +559,11 @@ trait Printers extends api.Printers { self: SymbolTable => if (isError) print(": error>") } else if (hasSymbolField) { tree match { - case _: Ident | _: Select | _: SelectFromTypeTree => print(tree.symbol) - case _ => print(tree.symbol.name) + case refTree: RefTree => + if (tree.symbol.name != refTree.name) print("[", tree.symbol, " aka ", refTree.name, "]") + else print(tree.symbol) + case _ => + print(tree.symbol.name) } } else { print(name) diff --git a/src/reflect/scala/reflect/internal/StdAttachments.scala b/src/reflect/scala/reflect/internal/StdAttachments.scala index 9fe443bf50..1df91a67b0 100644 --- a/src/reflect/scala/reflect/internal/StdAttachments.scala +++ b/src/reflect/scala/reflect/internal/StdAttachments.scala @@ -19,9 +19,26 @@ trait StdAttachments { def setPos(newpos: Position): this.type = { pos = newpos; this } } + /** When present, indicates that the host `Ident` has been created from a backquoted identifier. + */ case object BackquotedIdentifierAttachment + /** Stores the trees that give rise to a refined type to be used in reification. + * Unfortunately typed `CompoundTypeTree` is lacking essential info, and the reifier cannot use `CompoundTypeTree.tpe`. + * Therefore we need this hack (see `Reshape.toPreTyperTypeTree` for a detailed explanation). + */ case class CompoundTypeTreeOriginalAttachment(parents: List[Tree], stats: List[Tree]) + /** Is added by the macro engine to the results of macro expansions. + * Stores the original expandee as it entered the `macroExpand` function. + */ case class MacroExpansionAttachment(original: Tree) + + /** When present, suppresses macro expansion for the host. + * This is occasionally necessary, e.g. to prohibit eta-expansion of macros. + * + * Does not affect expandability of child nodes, there's context.withMacrosDisabled for that + * (but think thrice before using that API - see the discussion at https://github.com/scala/scala/pull/1639). + */ + case object SuppressMacroExpansionAttachment } diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 032c75f6df..ad7dbe5ef1 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -404,9 +404,9 @@ trait Symbols extends api.Symbols { self: SymbolTable => * failure to the point when that name is used for something, which is * often to the point of never. */ - def newStubSymbol(name: Name): Symbol = name match { - case n: TypeName => new StubClassSymbol(this, n) - case _ => new StubTermSymbol(this, name.toTermName) + def newStubSymbol(name: Name, missingMessage: String): Symbol = name match { + case n: TypeName => new StubClassSymbol(this, n, missingMessage) + case _ => new StubTermSymbol(this, name.toTermName, missingMessage) } @deprecated("Use the other signature", "2.10.0") @@ -1360,6 +1360,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 @@ -3066,14 +3069,20 @@ trait Symbols extends api.Symbols { self: SymbolTable => ) } trait StubSymbol extends Symbol { - protected def stubWarning = { - val from = if (associatedFile == null) "" else s" - referenced from ${associatedFile.canonicalPath}" - s"$kindString $nameString$locationString$from (a classfile may be missing)" - } + devWarning("creating stub symbol to defer error: " + missingMessage) + + protected def missingMessage: String + + /** Fail the stub by throwing a [[scala.reflect.internal.MissingRequirementError]]. */ + override final def failIfStub() = {MissingRequirementError.signal(missingMessage)} // + + /** Fail the stub by reporting an error to the reporter, setting the IS_ERROR flag + * on this symbol, and returning the dummy value `alt`. + */ private def fail[T](alt: T): T = { // Avoid issuing lots of redundant errors if (!hasFlag(IS_ERROR)) { - globalError(s"bad symbolic reference to " + stubWarning) + globalError(missingMessage) if (settings.debug.value) (new Throwable).printStackTrace @@ -3089,13 +3098,9 @@ trait Symbols extends api.Symbols { self: SymbolTable => override def info = fail(NoType) override def rawInfo = fail(NoType) override def companionSymbol = fail(NoSymbol) - - locally { - devWarning("creating stub symbol for " + stubWarning) - } } - class StubClassSymbol(owner0: Symbol, name0: TypeName) extends ClassSymbol(owner0, owner0.pos, name0) with StubSymbol - class StubTermSymbol(owner0: Symbol, name0: TermName) extends TermSymbol(owner0, owner0.pos, name0) with StubSymbol + class StubClassSymbol(owner0: Symbol, name0: TypeName, protected val missingMessage: String) extends ClassSymbol(owner0, owner0.pos, name0) with StubSymbol + class StubTermSymbol(owner0: Symbol, name0: TermName, protected val missingMessage: String) extends TermSymbol(owner0, owner0.pos, name0) with StubSymbol trait FreeSymbol extends Symbol { def origin: String diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 50b07f0cc8..f944e1d5d1 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -493,6 +493,10 @@ trait Trees extends api.Trees { self: SymbolTable => case class TypeTree() extends TypTree with TypeTreeContextApi { private var orig: Tree = null + /** Was this type tree originally empty? That is, does it now contain + * an inferred type that must be forgotten in `resetAttrs` to + * enable retyping. + */ private[scala] var wasEmpty: Boolean = false override def symbol = typeTreeSymbol(this) // if (tpe == null) null else tpe.typeSymbol @@ -513,6 +517,15 @@ trait Trees extends api.Trees { self: SymbolTable => wasEmpty = isEmpty setType(tp) } + + override private[scala] def copyAttrs(tree: Tree) = { + super.copyAttrs(tree) + tree match { + case other: TypeTree => wasEmpty = other.wasEmpty // SI-6648 Critical for correct operation of `resetAttrs`. + case _ => + } + this + } } object TypeTree extends TypeTreeExtractor diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 8bcccbf33e..09fc534d8a 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -1334,7 +1334,12 @@ 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) + if (!sym.isClass) { + // SI-6640 allow StubSymbols to reveal what's missing from the classpath before we trip the assertion. + sym.failIfStub() + assert(false, sym) + } + override def isTrivial: Boolean = sym.isPackageClass override def isNotNull = true override def typeSymbol = sym diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index 2dab9b37b4..5a0454a569 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._ @@ -232,7 +232,12 @@ 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. - owner.newStubSymbol(name) + val missingMessage = + s"""|bad symbolic reference. A signature in $filename refers to ${name.longString} + |in ${owner.kindString} ${owner.fullName} 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) } } } |