diff options
Diffstat (limited to 'src/compiler')
4 files changed, 26 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 531d7ec1e0..d6fa42b1cc 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -955,7 +955,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, false) { (s, st) => - new ScopeMember(s, st, context.isAccessible(s, pre, 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/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index abd3262c56..df220b7381 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -918,11 +918,24 @@ abstract class Erasure extends AddInterfaces } val decls = root.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. + afterPostErasure(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(e1.sym, e.sym)) doubleDefError(e.sym, e1.sym) e1 = decls.lookupNextEntry(e1) } diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 5d6d094b44..a7b0e47214 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -1294,7 +1294,7 @@ trait ContextErrors { private def compatibilityError(message: String) = implRefError( - "macro implementation has wrong shape:"+ + "macro implementation has incompatible shape:"+ "\n required: " + showMeth(rparamss, rret, abbreviate = true) + "\n found : " + showMeth(aparamss, aret, abbreviate = false) + "\n" + message) @@ -1328,7 +1328,11 @@ trait ContextErrors { def MacroImplOverloadedError() = implRefError("macro implementation cannot be overloaded") - def MacroImplWrongNumberOfTypeArgumentsError(macroImplRef: Tree) = implRefError(typer.TyperErrorGen.TypedApplyWrongNumberOfTpeParametersErrorMessage(macroImplRef)) + def MacroImplWrongNumberOfTypeArgumentsError(macroImplRef: Tree) = { + val MacroImplReference(owner, meth, targs) = macroImplRef + val diagnostic = if (meth.typeParams.length > targs.length) "has too few type arguments" else "has too many arguments" + implRefError(s"macro implementation reference $diagnostic for " + treeSymTypeMsg(macroImplRef)) + } def MacroImplNotStaticError() = implRefError("macro implementation must be in statically accessible object") @@ -1336,7 +1340,7 @@ trait ContextErrors { // aXXX (e.g. aparams) => characteristics of the macro impl ("a" stands for "actual") // rXXX (e.g. rparams) => characteristics of a reference macro impl signature synthesized from the macro def ("r" stands for "reference") - def MacroImplNonTagImplicitParameters(params: List[Symbol]) = compatibilityError("macro implementations cannot have implicit parameters other than WeakTypeTag evidences") + def MacroImplNonTagImplicitParameters(params: List[Symbol]) = implRefError("macro implementations cannot have implicit parameters other than WeakTypeTag evidences") def MacroImplParamssMismatchError() = compatibilityError("number of parameter sections differ") diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index b80dcefef8..40313bdb5d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3826,7 +3826,7 @@ trait Typers extends Modes with Adaptations with Tags { val normalizeLocals = 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) |