diff options
Diffstat (limited to 'src')
15 files changed, 70 insertions, 80 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 3025e4c440..1554be6ebb 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -133,24 +133,16 @@ trait Scanners extends ScannersCommon { /** Should doc comments be built? */ def buildDocs: Boolean = forScaladoc - /** buffer for the documentation comment + /** holder for the documentation comment */ - var docBuffer: StringBuilder = null - var docPos: Position = null + var docComment: DocComment = null - /** Return current docBuffer and set docBuffer to null */ def flushDoc: DocComment = { - val ret = if (docBuffer != null) DocComment(docBuffer.toString, docPos) else null - docBuffer = null + val ret = docComment + docComment = null ret } - /** add the given character to the documentation buffer - */ - protected def putDocChar(c: Char) { - if (docBuffer ne null) docBuffer.append(c) - } - protected def foundComment(value: String, start: Int, end: Int) = () protected def foundDocComment(value: String, start: Int, end: Int) = () @@ -227,11 +219,11 @@ trait Scanners extends ScannersCommon { while (!sepRegions.isEmpty && sepRegions.head != RBRACE) sepRegions = sepRegions.tail if (!sepRegions.isEmpty) sepRegions = sepRegions.tail - docBuffer = null + docComment = null case RBRACKET | RPAREN => if (!sepRegions.isEmpty && sepRegions.head == lastToken) sepRegions = sepRegions.tail - docBuffer = null + docComment = null case ARROW => if (!sepRegions.isEmpty && sepRegions.head == lastToken) sepRegions = sepRegions.tail @@ -537,7 +529,7 @@ trait Scanners extends ScannersCommon { nextChar() } while ((ch != CR) && (ch != LF) && (ch != SU)) } else { - docBuffer = null + docComment = null var openComments = 1 appendToComment() nextChar() @@ -545,24 +537,23 @@ trait Scanners extends ScannersCommon { var buildingDocComment = false if (ch == '*' && buildDocs) { buildingDocComment = true - docBuffer = new StringBuilder("/**") } while (openComments > 0) { do { do { if (ch == '/') { - nextChar(); putDocChar(ch); appendToComment() + nextChar(); appendToComment() if (ch == '*') { - nextChar(); putDocChar(ch); appendToComment() + nextChar(); appendToComment() openComments += 1 } } if (ch != '*' && ch != SU) { - nextChar(); putDocChar(ch); appendToComment() + nextChar(); appendToComment() } } while (ch != '*' && ch != SU) while (ch == '*') { - nextChar(); putDocChar(ch); appendToComment() + nextChar(); appendToComment() } } while (ch != '/' && ch != SU) if (ch == '/') nextChar() @@ -1297,7 +1288,8 @@ trait Scanners extends ScannersCommon { } override def foundDocComment(value: String, start: Int, end: Int) { - docPos = new RangePosition(unit.source, start, start, end) + val docPos = new RangePosition(unit.source, start, start, end) + docComment = new DocComment(value, docPos) unit.comment(docPos, value) } } diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index 5497719f89..add932441d 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -567,7 +567,7 @@ abstract class TreeBuilder { if (contextBounds.isEmpty) vparamss else { val mods = Modifiers(if (owner.isTypeName) PARAMACCESSOR | LOCAL | PRIVATE else PARAM) - def makeEvidenceParam(tpt: Tree) = ValDef(mods | IMPLICIT, freshTermName(nme.EVIDENCE_PARAM_PREFIX), tpt, EmptyTree) + def makeEvidenceParam(tpt: Tree) = ValDef(mods | IMPLICIT | SYNTHETIC, freshTermName(nme.EVIDENCE_PARAM_PREFIX), tpt, EmptyTree) val evidenceParams = contextBounds map makeEvidenceParam val vparamssLast = if(vparamss.nonEmpty) vparamss.last else Nil diff --git a/src/compiler/scala/tools/nsc/doc/base/MemberLookupBase.scala b/src/compiler/scala/tools/nsc/doc/base/MemberLookupBase.scala index 216157e19a..8d80333195 100755 --- a/src/compiler/scala/tools/nsc/doc/base/MemberLookupBase.scala +++ b/src/compiler/scala/tools/nsc/doc/base/MemberLookupBase.scala @@ -10,15 +10,15 @@ import comment._ trait MemberLookupBase { val global: Global - val settings: doc.Settings - import global._ + def internalLink(sym: Symbol, site: Symbol): Option[LinkTo] def chooseLink(links: List[LinkTo]): LinkTo def toString(link: LinkTo): String + def findExternalLink(sym: Symbol, name: String): Option[LinkToExternal] + def warnNoLink: Boolean import global._ - import definitions.{ NothingClass, AnyClass, AnyValClass, AnyRefClass, ListClass } import rootMirror.{RootPackage, EmptyPackage} private def isRoot(s: Symbol) = s.isRootSymbol || s.isEmptyPackage || s.isEmptyPackageClass @@ -83,7 +83,7 @@ trait MemberLookupBase { } links match { case Nil => - if (!settings.docNoLinkWarnings.value) + if (warnNoLink) reporter.warning(pos, "Could not find any member to link for \"" + query + "\".") // (4) if we still haven't found anything, create a tooltip Tooltip(query) @@ -95,7 +95,7 @@ trait MemberLookupBase { if (link == chosen) " [chosen]" else "" toString(link) + chosenInfo + "\n" } - if (!settings.docNoLinkWarnings.value) { + if (warnNoLink) { val allLinks = links.map(linkToString).mkString reporter.warning(pos, s"""The link target \"$query\" is ambiguous. Several members fit the target: @@ -199,29 +199,6 @@ trait MemberLookupBase { members.reverse } - - def findExternalLink(sym: Symbol, name: String): Option[LinkToExternal] = { - val sym1 = - if (sym == AnyClass || sym == AnyRefClass || sym == AnyValClass || sym == NothingClass) ListClass - else if (sym.isPackage) - /* Get package object which has associatedFile ne null */ - sym.info.member(newTermName("package")) - else sym - sym1.associatedFile.underlyingSource flatMap { src => - val path = src.path - settings.extUrlMapping get path map { url => - LinkToExternal(name, url + "#" + name) - } - } orElse { - // Deprecated option. - settings.extUrlPackageMapping find { - case (pkg, _) => name startsWith pkg - } map { - case (_, url) => LinkToExternal(name, url + "#" + name) - } - } - } - def externalSignature(sym: Symbol) = { sym.info // force it, otherwise we see lazy types (sym.nameString + sym.signatureString).replaceAll("\\s", "") diff --git a/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala b/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala index c7a767f992..23259a4ae8 100644 --- a/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala +++ b/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala @@ -9,6 +9,7 @@ trait MemberLookup extends base.MemberLookupBase { thisFactory: ModelFactory => import global._ + import definitions.{ NothingClass, AnyClass, AnyValClass, AnyRefClass, ListClass } override def internalLink(sym: Symbol, site: Symbol): Option[LinkTo] = findTemplateMaybe(sym) match { @@ -35,4 +36,28 @@ trait MemberLookup extends base.MemberLookupBase { mbr.sym.signatureString + " in " + inTpl.sym.toString case _ => link.toString } + + override def findExternalLink(sym: Symbol, name: String): Option[LinkToExternal] = { + val sym1 = + if (sym == AnyClass || sym == AnyRefClass || sym == AnyValClass || sym == NothingClass) ListClass + else if (sym.isPackage) + /* Get package object which has associatedFile ne null */ + sym.info.member(newTermName("package")) + else sym + Option(sym1.associatedFile) flatMap (_.underlyingSource) flatMap { src => + val path = src.path + settings.extUrlMapping get path map { url => + LinkToExternal(name, url + "#" + name) + } + } orElse { + // Deprecated option. + settings.extUrlPackageMapping find { + case (pkg, _) => name startsWith pkg + } map { + case (_, url) => LinkToExternal(name, url + "#" + name) + } + } + } + + override def warnNoLink = !settings.docNoLinkWarnings.value } diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 9bb2d552be..b0318f40c4 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -69,7 +69,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") if (verboseIDE) println("[%s][%s]".format(projectName, msg)) override def forInteractive = true - override def forScaladoc = settings.isScaladoc /** A map of all loaded files to the rich compilation units that correspond to them. */ diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala index 034a844e2e..5cda0e53fb 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/PresentationCompilerInstance.scala @@ -7,7 +7,7 @@ import reporters.{Reporter => CompilerReporter} /** Trait encapsulating the creation of a presentation compiler's instance.*/ private[tests] trait PresentationCompilerInstance extends TestSettings { protected val settings = new Settings - protected val docSettings = new doc.Settings(_ => ()) + protected val withDocComments = false protected val compilerReporter: CompilerReporter = new InteractiveReporter { override def compiler = PresentationCompilerInstance.this.compiler @@ -15,7 +15,9 @@ private[tests] trait PresentationCompilerInstance extends TestSettings { protected lazy val compiler: Global = { prepareSettings(settings) - new Global(settings, compilerReporter) + new Global(settings, compilerReporter) { + override def forScaladoc = withDocComments + } } /** diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index fb8d6b934f..8829a9a92e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -331,7 +331,7 @@ trait Macros extends scala.tools.reflect.FastTrack with Traces { def param(tree: Tree): Symbol = ( cache.getOrElseUpdate(tree.symbol, { val sym = tree.symbol - makeParam(sym.name, sym.pos, implType(sym.isType, sym.tpe), sym getFlag SYNTHETIC) + makeParam(sym.name, sym.pos, implType(sym.isType, sym.tpe), sym.flags) }) ) } diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 0992cd7955..f2129992e5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -67,7 +67,10 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT case t => t } acc setInfoAndEnter (tpe cloneInfo acc) - storeAccessorDefinition(clazz, DefDef(acc, EmptyTree)) + // Diagnostic for SI-7091 + if (!accDefs.contains(clazz)) + reporter.error(sel.pos, s"Internal error: unable to store accessor definition in ${clazz}. clazz.isPackage=${clazz.isPackage}. Accessor required for ${sel} (${showRaw(sel)})") + else storeAccessorDefinition(clazz, DefDef(acc, EmptyTree)) acc } @@ -288,6 +291,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT currentClass.isTrait && sym.isProtected && sym.enclClass != currentClass + && !sym.owner.isPackageClass // SI-7091 no accessor needed package owned (ie, top level) symbols && !sym.owner.isTrait && (sym.owner.enclosingPackageClass != currentClass.enclosingPackageClass) && (qual.symbol.info.member(sym.name) ne NoSymbol) diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index cfe962d65f..81ea5630d0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -101,14 +101,9 @@ trait TypeDiagnostics { "\n(Note that variables need to be initialized to be defined)" else "" - /** Only prints the parameter names if they're not synthetic, - * since "x$1: Int" does not offer any more information than "Int". - */ private def methodTypeErrorString(tp: Type) = tp match { case mt @ MethodType(params, resultType) => - def forString = - if (params exists (_.isSynthetic)) params map (_.tpe) - else params map (_.defString) + def forString = params map (_.defString) forString.mkString("(", ",", ")") + resultType case x => x.toString diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index c1fcff0c4e..561ca7f382 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4070,15 +4070,11 @@ trait Typers extends Adaptations with Tags { def resultingTypeTree(tpe: Type) = { // we need symbol-ful originals for reification // hence we go the extra mile to hand-craft tis guy - val original = - if (arg1.isType) - arg1 match { - case tt @ TypeTree() => Annotated(ann, tt.original) - // this clause is needed to correctly compile stuff like "new C @D" or "@(inline @getter)" - case _ => Annotated(ann, arg1) - } - else - tree + val original = arg1 match { + case tt @ TypeTree() => Annotated(ann, tt.original) + // this clause is needed to correctly compile stuff like "new C @D" or "@(inline @getter)" + case _ => Annotated(ann, arg1) + } original setType ann.tpe TypeTree(tpe) setOriginal original setPos tree.pos.focus } diff --git a/src/library/scala/collection/mutable/ArrayBuffer.scala b/src/library/scala/collection/mutable/ArrayBuffer.scala index 0877bfbb69..f1cfd2d69a 100644 --- a/src/library/scala/collection/mutable/ArrayBuffer.scala +++ b/src/library/scala/collection/mutable/ArrayBuffer.scala @@ -107,7 +107,7 @@ class ArrayBuffer[A](override protected val initialSize: Int) * the identity of the buffer. It takes time linear in * the buffer size. * - * @param elem the element to append. + * @param elem the element to prepend. * @return the updated buffer. */ def +=:(elem: A): this.type = { diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 36f3be341f..0670da137c 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -299,8 +299,8 @@ trait Future[+T] extends Awaitable[T] { * val f = future { 5 } * val g = f filter { _ % 2 == 1 } * val h = f filter { _ % 2 == 0 } - * await(g, 0) // evaluates to 5 - * await(h, 0) // throw a NoSuchElementException + * Await.result(g, Duration.Zero) // evaluates to 5 + * Await.result(h, Duration.Zero) // throw a NoSuchElementException * }}} */ def filter(pred: T => Boolean)(implicit executor: ExecutionContext): Future[T] = { @@ -348,8 +348,8 @@ trait Future[+T] extends Awaitable[T] { * val h = f collect { * case x if x > 0 => x * 2 * } - * await(g, 0) // evaluates to 5 - * await(h, 0) // throw a NoSuchElementException + * Await.result(g, Duration.Zero) // evaluates to 5 + * Await.result(h, Duration.Zero) // throw a NoSuchElementException * }}} */ def collect[S](pf: PartialFunction[T, S])(implicit executor: ExecutionContext): Future[S] = { @@ -454,7 +454,7 @@ trait Future[+T] extends Awaitable[T] { * val f = future { sys.error("failed") } * val g = future { 5 } * val h = f fallbackTo g - * await(h, 0) // evaluates to 5 + * Await.result(h, Duration.Zero) // evaluates to 5 * }}} */ def fallbackTo[U >: T](that: Future[U]): Future[U] = { @@ -634,7 +634,7 @@ object Future { * * Example: * {{{ - * val result = Await.result(Futures.reduce(futures)(_ + _), 5 seconds) + * val result = Await.result(Future.reduce(futures)(_ + _), 5 seconds) * }}} */ def reduce[T, R >: T](futures: TraversableOnce[Future[T]])(op: (R, T) => R)(implicit executor: ExecutionContext): Future[R] = { diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index 8f86fd5aa7..feb538033b 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -247,7 +247,7 @@ class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericCo */ def gcd (that: BigInt): BigInt = new BigInt(this.bigInteger.gcd(that.bigInteger)) - /** Returns a BigInt whose value is (this mod m). + /** Returns a BigInt whose value is (this mod that). * This method differs from `%` in that it always returns a non-negative BigInt. */ def mod (that: BigInt): BigInt = new BigInt(this.bigInteger.mod(that.bigInteger)) diff --git a/src/reflect/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala index 45c5279574..06f6c46fc3 100644 --- a/src/reflect/scala/reflect/internal/Flags.scala +++ b/src/reflect/scala/reflect/internal/Flags.scala @@ -287,7 +287,7 @@ class Flags extends ModifierFlags { * from Modifiers. Others which may be applied at creation time are: * SYNTHETIC. */ - final val ValueParameterFlags = BYNAMEPARAM | IMPLICIT | DEFAULTPARAM | STABLE + final val ValueParameterFlags = BYNAMEPARAM | IMPLICIT | DEFAULTPARAM | STABLE | SYNTHETIC final val BeanPropertyFlags = DEFERRED | OVERRIDE | STATIC final val VarianceFlags = COVARIANT | CONTRAVARIANT diff --git a/src/reflect/scala/reflect/internal/util/Statistics.scala b/src/reflect/scala/reflect/internal/util/Statistics.scala index b078b7d4f9..0fa798058d 100644 --- a/src/reflect/scala/reflect/internal/util/Statistics.scala +++ b/src/reflect/scala/reflect/internal/util/Statistics.scala @@ -109,7 +109,7 @@ quant) * Quantities with non-empty prefix are printed in the statistics info. */ trait Quantity { - if (prefix.nonEmpty) { + if (enabled && prefix.nonEmpty) { val key = s"${if (underlying != this) underlying.prefix else ""}/$prefix" qs(key) = this } |