summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/interactive/CompilerControl.scala23
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Global.scala7
-rw-r--r--src/compiler/scala/tools/nsc/interactive/Picklers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/REPL.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala13
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala10
7 files changed, 43 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
index af82957a2e..8d12581c9c 100644
--- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
+++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala
@@ -202,15 +202,20 @@ trait CompilerControl { self: Global =>
postWorkItem(new AskToDoFirstItem(source))
/** If source is not yet loaded, loads it, and starts a new run, otherwise
- * continues with current pass.
- * Waits until source is fully type checked and returns body in response.
- * @param source The source file that needs to be fully typed.
- * @param response The response, which is set to the fully attributed tree of `source`.
+ * continues with current pass.
+ * Waits until source is fully type checked and returns body in response.
+ * @param source The source file that needs to be fully typed.
+ * @param keepLoaded Whether to keep that file in the PC if it was not loaded before. If
+ the file is already loaded, this flag is ignored.
+ * @param response The response, which is set to the fully attributed tree of `source`.
* If the unit corresponding to `source` has been removed in the meantime
* the a NoSuchUnitError is raised in the response.
*/
- def askLoadedTyped(source: SourceFile, response: Response[Tree]) =
- postWorkItem(new AskLoadedTypedItem(source, response))
+ def askLoadedTyped(source:SourceFile, keepLoaded: Boolean, response: Response[Tree]): Unit =
+ postWorkItem(new AskLoadedTypedItem(source, keepLoaded, response))
+
+ final def askLoadedTyped(source: SourceFile, response: Response[Tree]): Unit =
+ askLoadedTyped(source, false, response)
/** If source if not yet loaded, get an outline view with askParseEntered.
* If source is loaded, wait for it to be typechecked.
@@ -219,7 +224,7 @@ trait CompilerControl { self: Global =>
*/
def askStructure(keepSrcLoaded: Boolean)(source: SourceFile, response: Response[Tree]) = {
getUnit(source) match {
- case Some(_) => askLoadedTyped(source, response)
+ case Some(_) => askLoadedTyped(source, keepSrcLoaded, response)
case None => askParsedEntered(source, keepSrcLoaded, response)
}
}
@@ -403,8 +408,8 @@ trait CompilerControl { self: Global =>
response raise new MissingResponse
}
- case class AskLoadedTypedItem(val source: SourceFile, response: Response[Tree]) extends WorkItem {
- def apply() = self.waitLoadedTyped(source, response, this.onCompilerThread)
+ case class AskLoadedTypedItem(val source: SourceFile, keepLoaded: Boolean, response: Response[Tree]) extends WorkItem {
+ def apply() = self.waitLoadedTyped(source, response, keepLoaded, this.onCompilerThread)
override def toString = "wait loaded & typed "+source
def raiseMissing() =
diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala
index a8d6f8977c..d6fa42b1cc 100644
--- a/src/compiler/scala/tools/nsc/interactive/Global.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Global.scala
@@ -1076,7 +1076,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
}
/** Implements CompilerControl.askLoadedTyped */
- private[interactive] def waitLoadedTyped(source: SourceFile, response: Response[Tree], onSameThread: Boolean = true) {
+ private[interactive] def waitLoadedTyped(source: SourceFile, response: Response[Tree], keepLoaded: Boolean = false, onSameThread: Boolean = true) {
getUnit(source) match {
case Some(unit) =>
if (unit.isUpToDate) {
@@ -1094,7 +1094,10 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
case None =>
debugLog("load unit and type")
try reloadSources(List(source))
- finally waitLoadedTyped(source, response, onSameThread)
+ finally {
+ waitLoadedTyped(source, response, onSameThread)
+ if (!keepLoaded) removeUnitOf(source)
+ }
}
}
diff --git a/src/compiler/scala/tools/nsc/interactive/Picklers.scala b/src/compiler/scala/tools/nsc/interactive/Picklers.scala
index 2b389158c3..64e050e799 100644
--- a/src/compiler/scala/tools/nsc/interactive/Picklers.scala
+++ b/src/compiler/scala/tools/nsc/interactive/Picklers.scala
@@ -172,7 +172,7 @@ trait Picklers { self: Global =>
implicit def askLoadedTypedItem: CondPickler[AskLoadedTypedItem] =
pkl[SourceFile]
- .wrapped { source => new AskLoadedTypedItem(source, new Response) } { _.source }
+ .wrapped { source => new AskLoadedTypedItem(source, false, new Response) } { _.source }
.asClass (classOf[AskLoadedTypedItem])
implicit def askParsedEnteredItem: CondPickler[AskParsedEnteredItem] =
diff --git a/src/compiler/scala/tools/nsc/interactive/REPL.scala b/src/compiler/scala/tools/nsc/interactive/REPL.scala
index 7b89d5b0aa..4b64313e1b 100644
--- a/src/compiler/scala/tools/nsc/interactive/REPL.scala
+++ b/src/compiler/scala/tools/nsc/interactive/REPL.scala
@@ -170,7 +170,7 @@ object REPL {
comp.askReload(List(toSourceFile(file)), reloadResult)
Thread.sleep(millis.toInt)
println("ask type now")
- comp.askLoadedTyped(toSourceFile(file), typedResult)
+ comp.askLoadedTyped(toSourceFile(file), keepLoaded = true, typedResult)
typedResult.get
case List("typeat", file, off1, off2) =>
doTypeAt(makePos(file, off1, off2))
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala
index 4f9df6808f..d5da52bc13 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala
@@ -113,9 +113,9 @@ trait AskTypeAt extends AskCommand {
trait AskLoadedTyped extends AskCommand {
import compiler.Tree
- protected def askLoadedTyped(source: SourceFile)(implicit reporter: Reporter): Response[Tree] = {
+ protected def askLoadedTyped(source: SourceFile, keepLoaded: Boolean = false)(implicit reporter: Reporter): Response[Tree] = {
ask {
- compiler.askLoadedTyped(source, _)
+ compiler.askLoadedTyped(source, keepLoaded, _)
}
}
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")