diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-12-13 10:07:09 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-12-13 10:07:09 -0800 |
commit | 1e530365fd3a1ab749091e7c56850405dc98aed1 (patch) | |
tree | e98e6e16c5f6fd003ef4c6581fa8a97f215ccfed /src | |
parent | d614965f083981817bfa08b84a07c069987d0a78 (diff) | |
parent | 3bfd83971ec48102fd1e711236f5a313c6a1ce3e (diff) | |
download | scala-1e530365fd3a1ab749091e7c56850405dc98aed1.tar.gz scala-1e530365fd3a1ab749091e7c56850405dc98aed1.tar.bz2 scala-1e530365fd3a1ab749091e7c56850405dc98aed1.zip |
Merge pull request #3265 from retronym/merge/2.10.x-to-master
Merge 2.10.x to master
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 13 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 | ||||
-rw-r--r-- | src/interactive/scala/tools/nsc/interactive/Global.scala | 6 | ||||
-rw-r--r-- | src/library/scala/MatchError.scala | 10 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 9 | ||||
-rw-r--r-- | src/swing/scala/swing/Publisher.scala | 2 |
6 files changed, 36 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 6fe0f34105..6732900ef2 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -714,11 +714,24 @@ abstract class Erasure extends AddInterfaces /** TODO - adapt SymbolPairs so it can be used here. */ private def checkNoDeclaredDoubleDefs(base: Symbol) { val decls = base.info.decls + + // SI-8010 force infos, otherwise makeNotPrivate in ExplicitOuter info transformer can trigger + // a scope rehash while were iterating and we can see the same entry twice! + // Inspection of SymbolPairs (the basis of OverridingPairs), suggests that it is immune + // from this sort of bug as it copies the symbols into a temporary scope *before* any calls to `.info`, + // ie, no variant of it calls `info` or `tpe` in `SymbolPair#exclude`. + // + // Why not just create a temporary scope here? We need to force the name changes in any case before + // we do these checks, so that we're comparing same-named methods based on the expanded names that actually + // end up in the bytecode. + exitingPostErasure(decls.foreach(_.info)) + var e = decls.elems while (e ne null) { if (e.sym.isTerm) { var e1 = decls lookupNextEntry e while (e1 ne null) { + assert(e.sym ne e1.sym, s"Internal error: encountered ${e.sym.debugLocationString} twice during scope traversal. This might be related to SI-8010.") if (sameTypeAfterErasure(e.sym, e1.sym)) doubleDefError(new SymbolPair(base, e.sym, e1.sym)) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 520b55400c..5e89440bc0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3746,7 +3746,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper val dealiasLocals = new TypeMap { def apply(tp: Type): Type = tp match { case TypeRef(pre, sym, args) => - if (sym.isAliasType && containsLocal(tp)) apply(tp.dealias) + if (sym.isAliasType && containsLocal(tp) && (tp.dealias ne tp)) apply(tp.dealias) else { if (pre.isVolatile) InferTypeWithVolatileTypeSelectionError(tree, pre) diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala index 467a210cab..92c69dfcde 100644 --- a/src/interactive/scala/tools/nsc/interactive/Global.scala +++ b/src/interactive/scala/tools/nsc/interactive/Global.scala @@ -1018,7 +1018,11 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") val enclosing = new Members[ScopeMember] def addScopeMember(sym: Symbol, pre: Type, viaImport: Tree) = locals.add(sym, pre, implicitlyAdded = false) { (s, st) => - new ScopeMember(s, st, context.isAccessible(s, pre, superAccess = false), viaImport) + // imported val and var are always marked as inaccessible, but they could be accessed through their getters. SI-7995 + if (s.hasGetter) + new ScopeMember(s, st, context.isAccessible(s.getter, pre, superAccess = false), viaImport) + else + new ScopeMember(s, st, context.isAccessible(s, pre, superAccess = false), viaImport) } def localsToEnclosing() = { enclosing.addNonShadowed(locals) diff --git a/src/library/scala/MatchError.scala b/src/library/scala/MatchError.scala index 6ba7e833d3..9965bb19b5 100644 --- a/src/library/scala/MatchError.scala +++ b/src/library/scala/MatchError.scala @@ -23,9 +23,15 @@ final class MatchError(obj: Any) extends RuntimeException { /** There's no reason we need to call toString eagerly, * so defer it until getMessage is called. */ - private lazy val objString = + private lazy val objString = { + def ofClass = "of class " + obj.getClass.getName if (obj == null) "null" - else obj.toString() + " (of class " + obj.getClass.getName + ")" + else try { + obj.toString() + " (" + ofClass + ")" + } catch { + case _: Throwable => "an instance " + ofClass + } + } override def getMessage() = objString } diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 85bc3158f6..52d035eadb 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -1379,6 +1379,13 @@ trait Symbols extends api.Symbols { self: SymbolTable => def hasRawInfo: Boolean = infos ne null def hasCompleteInfo = hasRawInfo && rawInfo.isComplete + // does not run adaptToNewRun, which is prone to trigger cycles (SI-8029) + // TODO: give this a better name if you understand the intent of the caller. + // Is it something to do with `reallyExists` or `isStale`? + final def rawInfoIsNoType: Boolean = { + hasRawInfo && (infos.info eq NoType) + } + /** Return info without checking for initialization or completing */ def rawInfo: Type = { var infos = this.infos @@ -2038,7 +2045,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** Is this symbol defined in the same scope and compilation unit as `that` symbol? */ def isCoDefinedWith(that: Symbol) = ( - (this.rawInfo ne NoType) + !rawInfoIsNoType && (this.effectiveOwner == that.effectiveOwner) && ( !this.effectiveOwner.isPackageClass || (this.associatedFile eq NoAbstractFile) diff --git a/src/swing/scala/swing/Publisher.scala b/src/swing/scala/swing/Publisher.scala index 96207de808..578ef71e09 100644 --- a/src/swing/scala/swing/Publisher.scala +++ b/src/swing/scala/swing/Publisher.scala @@ -44,7 +44,7 @@ trait Publisher extends Reactor { /** * Notify all registered reactions. */ - def publish(e: Event) { for (l <- listeners) l(e) } + def publish(e: Event) { for (l <- listeners) if (l.isDefinedAt(e)) l(e) } listenTo(this) } |