Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.10.x' into merge-2.10.x
Browse files Browse the repository at this point in the history
* origin/2.10.x: (31 commits)
  Implicit vars should have non-implicit setters.
  Deprecate `scala.tools.nsc.Phases` because it's dead-code.
  scaladoc Template: remove duplicate code and several usages of Option.get.
  adds scala-reflect.jar to MIMA in ant
  Test showing the absence of a forward reference
  update mailmap
  Remove dead code from `Global`.
  Cleanup MemberLookup. Better explain ambiguous link targets.
  typedIdent no longer destroys attachments
  fixes incorrect handling of Annotated in lazy copier
  simplifies checkBounds
  Recurse into instantiations when stripping type vars.
  Extract base scaladoc functionality for the IDE.
  Expand pattern match position tests.
  SI-6288 Remedy ill-positioned extractor binding.
  SI-6288 Fix positioning of label jumps
  SI-6288 Position argument of unapply
  Fixes SI-6758: force LazyAnnnotationInfo for DefDef and TypeDef
  SI-6795 Simplify errors related to "abstract override" on type members
  SI-6795 Adds negative check for "abstract override" on types in traits
  ...

Conflicts:
	.mailmap
	src/compiler/scala/tools/nsc/Global.scala
	src/compiler/scala/tools/nsc/ast/DocComments.scala
	src/compiler/scala/tools/nsc/doc/base/CommentFactoryBase.scala
	src/compiler/scala/tools/nsc/doc/html/page/Source.scala
	src/compiler/scala/tools/nsc/doc/html/page/Template.scala
	src/compiler/scala/tools/nsc/doc/model/LinkTo.scala
	src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala
	src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
	src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
	src/compiler/scala/tools/nsc/typechecker/Typers.scala
	src/reflect/scala/reflect/runtime/JavaMirrors.scala
	test/scaladoc/run/links.scala
  • Loading branch information
paulp committed Dec 20, 2012
2 parents a313fa1 + 9ddb4cf commit 106ca1b
Show file tree
Hide file tree
Showing 102 changed files with 1,504 additions and 610 deletions.
24 changes: 22 additions & 2 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
Aleksandar Prokopec <[email protected]>
Aleksandar Prokopec <aleksandar@aleksandar-Latitude-E6500.(none)>
Aleksandar Prokopec <aleksandar@htpc.(none)>
Aleksandar Prokopec <aleksandar@htpc-axel22.(none)>
Aleksandar Prokopec <aleksandar@htpc.(none)>
Aleksandar Prokopec <[email protected]>
Aleksandar Prokopec <[email protected]>
Antonio Cunei <[email protected]>
Caoyuan Deng <[email protected]>
Chris Hodapp <[email protected]>
Chris James <[email protected]>
Christopher Vogt <[email protected]>
Damien Obristi <[email protected]>
Daniel C. Sobral <dcs@dcs-132-CK-NF79.(none)>
Daniel C. Sobral <dcs@dcs-132-CK-NF79.(none)>
Ilya Sergei <[email protected]>
Ingo Maier <[email protected]>
Kenji Yoshida <[email protected]>
Luc Bourlier <[email protected]>
Martin Odersky <[email protected]>
Nada Amin <[email protected]>
Nada Amin <[email protected]>
Natallie Baikevich <[email protected]>
Pavel Pavlov <[email protected]>
Pavel Pavlov <[email protected]>
Philipp Haller <[email protected]>
Roland Kuhn <[email protected]>
Rüdiger Klaehn <[email protected]>
Stéphane Micheloud <[email protected]>
15 changes: 14 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2503,6 +2503,7 @@ Binary compatibility testing
</artifact:dependencies>
<artifact:dependencies pathId="old.bc.classpath">
<dependency groupId="org.scala-lang" artifactId="scala-library" version="2.10.0-RC2"/>
<dependency groupId="org.scala-lang" artifactId="scala-reflect" version="2.10.0-RC2"/>
</artifact:dependencies>
</target>

Expand All @@ -2518,7 +2519,19 @@ Binary compatibility testing
<classpath>
<path refid="mima.classpath"/>
</classpath>
</java>
</java>
<java
fork="true"
failonerror="true"
classname="com.typesafe.tools.mima.cli.Main">
<arg value="--prev"/>
<arg value="${org.scala-lang:scala-reflect:jar}"/>
<arg value="--curr"/>
<arg value="${build-pack.dir}/lib/scala-reflect.jar"/>
<classpath>
<path refid="mima.classpath"/>
</classpath>
</java>
</target>


Expand Down
6 changes: 3 additions & 3 deletions src/compiler/scala/tools/nsc/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ abstract class Driver {
doCompile(compiler)
} catch {
case ex: Throwable =>
compiler.logThrowable(ex)
compiler.reportThrowable(ex)
ex match {
case FatalError(msg) => reporter.error(null, "fatal error: " + msg)
case _ => throw ex
case FatalError(msg) => // signals that we should fail compilation.
case _ => throw ex // unexpected error, tell the outside world.
}
}
}
Expand Down
75 changes: 41 additions & 34 deletions src/compiler/scala/tools/nsc/Global.scala
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
log(msg)
}

def logThrowable(t: Throwable): Unit = globalError(throwableAsString(t))
@deprecated("Renamed to reportThrowable", "2.10.1")
def logThrowable(t: Throwable): Unit = reportThrowable(t)
def reportThrowable(t: Throwable): Unit = globalError(throwableAsString(t))
override def throwableAsString(t: Throwable) = util.stackTraceString(t)

// ------------ File interface -----------------------------------------
Expand Down Expand Up @@ -709,7 +711,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
/* The set of phase objects that is the basis for the compiler phase chain */
protected lazy val phasesSet = new mutable.HashSet[SubComponent]
protected lazy val phasesDescMap = new mutable.HashMap[SubComponent, String] withDefaultValue ""
private lazy val phaseTimings = new Phases.TimingModel // tracking phase stats

protected def addToPhasesSet(sub: SubComponent, descr: String) {
phasesSet += sub
Expand Down Expand Up @@ -1038,37 +1039,41 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
/** Don't want to introduce new errors trying to report errors,
* so swallow exceptions.
*/
override def supplementErrorMessage(errorMessage: String): String = try {
val tree = analyzer.lastTreeToTyper
val sym = tree.symbol
val tpe = tree.tpe
val enclosing = lastSeenContext.enclClassOrMethod.tree

val info1 = formatExplain(
"while compiling" -> currentSource.path,
"during phase" -> ( if (globalPhase eq phase) phase else "global=%s, enteringPhase=%s".format(globalPhase, phase) ),
"library version" -> scala.util.Properties.versionString,
"compiler version" -> Properties.versionString,
"reconstructed args" -> settings.recreateArgs.mkString(" ")
)
val info2 = formatExplain(
"last tree to typer" -> tree.summaryString,
"symbol" -> Option(sym).fold("null")(_.debugLocationString),
"symbol definition" -> Option(sym).fold("null")(_.defString),
"tpe" -> tpe,
"symbol owners" -> ownerChainString(sym),
"context owners" -> ownerChainString(lastSeenContext.owner)
)
val info3: List[String] = (
( List("== Enclosing template or block ==", nodePrinters.nodeToString(enclosing).trim) )
++ ( if (tpe eq null) Nil else List("== Expanded type of tree ==", typeDeconstruct.show(tpe)) )
++ ( if (!settings.debug.value) Nil else List("== Current unit body ==", nodePrinters.nodeToString(currentUnit.body)) )
++ ( List(errorMessage) )
)

("\n" + info1) :: info2 :: info3 mkString "\n\n"
}
catch { case x: Exception => errorMessage }
override def supplementErrorMessage(errorMessage: String): String =
if (currentRun.supplementedError) errorMessage
else try {
val tree = analyzer.lastTreeToTyper
val sym = tree.symbol
val tpe = tree.tpe
val enclosing = lastSeenContext.enclClassOrMethod.tree

val info1 = formatExplain(
"while compiling" -> currentSource.path,
"during phase" -> ( if (globalPhase eq phase) phase else "global=%s, enteringPhase=%s".format(globalPhase, phase) ),
"library version" -> scala.util.Properties.versionString,
"compiler version" -> Properties.versionString,
"reconstructed args" -> settings.recreateArgs.mkString(" ")
)
val info2 = formatExplain(
"last tree to typer" -> tree.summaryString,
"symbol" -> Option(sym).fold("null")(_.debugLocationString),
"symbol definition" -> Option(sym).fold("null")(_.defString),
"tpe" -> tpe,
"symbol owners" -> ownerChainString(sym),
"context owners" -> ownerChainString(lastSeenContext.owner)
)
val info3: List[String] = (
( List("== Enclosing template or block ==", nodePrinters.nodeToString(enclosing).trim) )
++ ( if (tpe eq null) Nil else List("== Expanded type of tree ==", typeDeconstruct.show(tpe)) )
++ ( if (!settings.debug.value) Nil else List("== Current unit body ==", nodePrinters.nodeToString(currentUnit.body)) )
++ ( List(errorMessage) )
)

currentRun.supplementedError = true

("\n" + info1) :: info2 :: info3 mkString "\n\n"
}
catch { case x: Exception => errorMessage }

/** The id of the currently active run
*/
Expand Down Expand Up @@ -1122,6 +1127,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
/** Has any macro expansion used a fallback during this run? */
var seenMacroExpansionsFallingBack = false

/** Have we already supplemented the error message of a compiler crash? */
private[nsc] final var supplementedError = false

private val unitbuf = new mutable.ListBuffer[CompilationUnit]
val compiledFiles = new mutable.HashSet[String]

Expand Down Expand Up @@ -1478,7 +1486,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)

// progress update
informTime(globalPhase.description, startTime)
phaseTimings(globalPhase) = currentTime - startTime
val shouldWriteIcode = (
(settings.writeICode.isSetByUser && (settings.writeICode containsPhase globalPhase))
|| (!settings.Xprint.doAllPhases && (settings.Xprint containsPhase globalPhase) && runIsAtOptimiz)
Expand Down
1 change: 1 addition & 0 deletions src/compiler/scala/tools/nsc/Phases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package scala.tools.nsc
import scala.reflect.internal.util.TableDef
import scala.language.postfixOps

@deprecated("Scheduled for removal as being a dead-code in the compiler.", "2.10.1")
object Phases {
val MaxPhases = 64

Expand Down
44 changes: 25 additions & 19 deletions src/compiler/scala/tools/nsc/ast/DocComments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,22 @@ import scala.collection.mutable
*/
trait DocComments { self: Global =>

var cookedDocComments = Map[Symbol, String]()
val cookedDocComments = mutable.HashMap[Symbol, String]()

/** The raw doc comment map */
val docComments = mutable.HashMap[Symbol, DocComment]()

def clearDocComments() {
cookedDocComments.clear()
docComments.clear()
defs.clear()
}

/** Associate comment with symbol `sym` at position `pos`. */
def docComment(sym: Symbol, docStr: String, pos: Position = NoPosition) =
if ((sym ne null) && (sym ne NoSymbol))
docComments += (sym -> DocComment(docStr, pos))

/** The raw doc comment of symbol `sym`, as it appears in the source text, "" if missing.
*/
def rawDocComment(sym: Symbol): String =
Expand All @@ -47,25 +58,20 @@ trait DocComments { self: Global =>
* If a symbol does not have a doc comment but some overridden version of it does,
* the doc comment of the overridden version is copied instead.
*/
def cookedDocComment(sym: Symbol, docStr: String = ""): String = cookedDocComments.get(sym) match {
case Some(comment) =>
comment
case None =>
val ownComment = if (docStr.length == 0) docComments get sym map (_.template) getOrElse ""
def cookedDocComment(sym: Symbol, docStr: String = ""): String = cookedDocComments.getOrElseUpdate(sym, {
val ownComment = if (docStr.length == 0) docComments get sym map (_.template) getOrElse ""
else DocComment(docStr).template
val comment = superComment(sym) match {
case None =>
if (ownComment.indexOf("@inheritdoc") != -1)
reporter.warning(sym.pos, "The comment for " + sym +
" contains @inheritdoc, but no parent comment is available to inherit from.")
ownComment.replaceAllLiterally("@inheritdoc", "<invalid inheritdoc annotation>")
case Some(sc) =>
if (ownComment == "") sc
else expandInheritdoc(sc, merge(sc, ownComment, sym), sym)
}
cookedDocComments += (sym -> comment)
comment
}
superComment(sym) match {
case None =>
if (ownComment.indexOf("@inheritdoc") != -1)
reporter.warning(sym.pos, "The comment for " + sym +
" contains @inheritdoc, but no parent comment is available to inherit from.")
ownComment.replaceAllLiterally("@inheritdoc", "<invalid inheritdoc annotation>")
case Some(sc) =>
if (ownComment == "") sc
else expandInheritdoc(sc, merge(sc, ownComment, sym), sym)
}
})

/** The cooked doc comment of symbol `sym` after variable expansion, or "" if missing.
*
Expand Down
7 changes: 6 additions & 1 deletion src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,12 @@ trait BasicBlocks {
else
instrs.zipWithIndex collect {
case (oldInstr, i) if map contains oldInstr =>
code.touched |= replaceInstruction(i, map(oldInstr))
// SI-6288 clone important here because `replaceInstruction` assigns
// a position to `newInstr`. Without this, a single instruction can
// be added twice, and the position last position assigned clobbers
// all previous positions in other usages.
val newInstr = map(oldInstr).clone()
code.touched |= replaceInstruction(i, newInstr)
}

////////////////////// Emit //////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/doc/DocFactory.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class DocFactory(val reporter: Reporter, val settings: doc.Settings) { processor
with model.ModelFactoryImplicitSupport
with model.ModelFactoryTypeSupport
with model.diagram.DiagramFactory
with model.comment.CommentFactory
with model.CommentFactory
with model.TreeFactory
with model.MemberLookup {
override def templateShouldDocument(sym: compiler.Symbol, inTpl: DocTemplateImpl) =
Expand Down
Loading

0 comments on commit 106ca1b

Please sign in to comment.