diff options
Diffstat (limited to 'src')
20 files changed, 78 insertions, 49 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/opt/BytecodeUtils.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/BytecodeUtils.scala index ff36f36589..9a90c53d3e 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/opt/BytecodeUtils.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/BytecodeUtils.scala @@ -125,7 +125,7 @@ object BytecodeUtils { } def sameTargetExecutableInstruction(a: JumpInsnNode, b: JumpInsnNode): Boolean = { - // Compare next executable instead of the the labels. Identifies a, b as the same target: + // Compare next executable instead of the labels. Identifies a, b as the same target: // LabelNode(a) // LabelNode(b) // Instr diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index f7a1f462b7..7cd05b56c3 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -651,7 +651,7 @@ abstract class UnCurry extends InfoTransform * This transformation erases the dependent method types by: * - Widening the formal parameter type to existentially abstract * over the prior parameters (using `packSymbols`). This transformation - * is performed in the the `InfoTransform`er [[scala.reflect.internal.transform.UnCurry]]. + * is performed in the `InfoTransform`er [[scala.reflect.internal.transform.UnCurry]]. * - Inserting casts in the method body to cast to the original, * precise type. * diff --git a/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala b/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala index 8b2e09495f..4ae97ce281 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala @@ -542,7 +542,7 @@ trait ScalaLogic extends Interface with Logic with TreeAndTypeAnalysis { * * (0) A or B must be in the domain to draw any conclusions. * - * For example, knowing the the scrutinee is *not* true does not + * For example, knowing the scrutinee is *not* true does not * statically exclude it from being `X`, because that is an opaque * Boolean. * diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala index 96a20ea631..e12b8548a8 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala @@ -503,14 +503,26 @@ trait MatchTranslation { */ def treeMaker(binder: Symbol, binderKnownNonNull: Boolean, pos: Position): TreeMaker = { val paramAccessors = binder.constrParamAccessors + val numParams = paramAccessors.length + def paramAccessorAt(subPatIndex: Int) = paramAccessors(math.min(subPatIndex, numParams - 1)) // binders corresponding to mutable fields should be stored (SI-5158, SI-6070) // make an exception for classes under the scala package as they should be well-behaved, // to optimize matching on List + val hasRepeated = paramAccessors.lastOption match { + case Some(x) => definitions.isRepeated(x) + case _ => false + } val mutableBinders = ( if (!binder.info.typeSymbol.hasTransOwner(ScalaPackageClass) && - (paramAccessors exists (_.isMutable))) - subPatBinders.zipWithIndex.collect{ case (binder, idx) if paramAccessors(idx).isMutable => binder } - else Nil + (paramAccessors exists (x => x.isMutable || definitions.isRepeated(x)))) { + + subPatBinders.zipWithIndex.flatMap { + case (binder, idx) => + val param = paramAccessorAt(idx) + if (param.isMutable || (definitions.isRepeated(param) && !aligner.isStar)) binder :: Nil + else Nil + } + } else Nil ) // checks binder ne null before chaining to the next extractor diff --git a/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala b/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala index 0574869714..9898cfd785 100644 --- a/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala +++ b/src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala @@ -65,7 +65,7 @@ trait AnalyzerPlugins { self: Analyzer => * The hooks into `typeSig` allow analyzer plugins to add annotations to (or change the types * of) definition symbols. This cannot not be achieved by using `pluginsTyped`: this method * is only called during type checking, so changing the type of a symbol at this point is too - * late: references to the symbol might already be typed and therefore obtain the the original + * late: references to the symbol might already be typed and therefore obtain the original * type assigned during naming. * * @param defTree is the definition for which the type was computed. The different cases are diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala index a702b3cdf5..f90e61ff92 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala @@ -79,7 +79,7 @@ trait PatternTypers { // do not update the symbol if the tree's symbol's type does not define an unapply member // (e.g. since it's some method that returns an object with an unapply member) val fun = inPlaceAdHocOverloadingResolution(fun0)(hasUnapplyMember) - val caseClass = fun.tpe.typeSymbol.linkedClassOfClass + val caseClass = companionSymbolOf(fun.tpe.typeSymbol.sourceModule, context) val member = unapplyMember(fun.tpe) def resultType = (fun.tpe memberType member).finalResultType def isEmptyType = resultOfMatchingMethod(resultType, nme.isEmpty)() diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala index 413231c0d1..fb662911b3 100644 --- a/src/library/scala/Byte.scala +++ b/src/library/scala/Byte.scala @@ -79,8 +79,8 @@ final abstract class Byte private extends AnyVal { */ def >>>(x: Long): Int /** - * Returns this value bit-shifted left by the specified number of bits, - * filling in the right bits with the same value as the left-most bit of this. + * Returns this value bit-shifted right by the specified number of bits, + * filling in the left bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ * -21 >> 3 == -3 @@ -90,8 +90,8 @@ final abstract class Byte private extends AnyVal { */ def >>(x: Int): Int /** - * Returns this value bit-shifted left by the specified number of bits, - * filling in the right bits with the same value as the left-most bit of this. + * Returns this value bit-shifted right by the specified number of bits, + * filling in the left bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ * -21 >> 3 == -3 diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala index ec2d48c181..9f06503569 100644 --- a/src/library/scala/Char.scala +++ b/src/library/scala/Char.scala @@ -79,8 +79,8 @@ final abstract class Char private extends AnyVal { */ def >>>(x: Long): Int /** - * Returns this value bit-shifted left by the specified number of bits, - * filling in the right bits with the same value as the left-most bit of this. + * Returns this value bit-shifted right by the specified number of bits, + * filling in the left bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ * -21 >> 3 == -3 @@ -90,8 +90,8 @@ final abstract class Char private extends AnyVal { */ def >>(x: Int): Int /** - * Returns this value bit-shifted left by the specified number of bits, - * filling in the right bits with the same value as the left-most bit of this. + * Returns this value bit-shifted right by the specified number of bits, + * filling in the left bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ * -21 >> 3 == -3 diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala index 72e5ebf81b..3bd3775eba 100644 --- a/src/library/scala/Int.scala +++ b/src/library/scala/Int.scala @@ -79,8 +79,8 @@ final abstract class Int private extends AnyVal { */ def >>>(x: Long): Int /** - * Returns this value bit-shifted left by the specified number of bits, - * filling in the right bits with the same value as the left-most bit of this. + * Returns this value bit-shifted right by the specified number of bits, + * filling in the left bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ * -21 >> 3 == -3 @@ -90,8 +90,8 @@ final abstract class Int private extends AnyVal { */ def >>(x: Int): Int /** - * Returns this value bit-shifted left by the specified number of bits, - * filling in the right bits with the same value as the left-most bit of this. + * Returns this value bit-shifted right by the specified number of bits, + * filling in the left bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ * -21 >> 3 == -3 diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala index 1bd0fe88b1..b27a66647f 100644 --- a/src/library/scala/Long.scala +++ b/src/library/scala/Long.scala @@ -79,8 +79,8 @@ final abstract class Long private extends AnyVal { */ def >>>(x: Long): Long /** - * Returns this value bit-shifted left by the specified number of bits, - * filling in the right bits with the same value as the left-most bit of this. + * Returns this value bit-shifted right by the specified number of bits, + * filling in the left bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ * -21 >> 3 == -3 @@ -90,8 +90,8 @@ final abstract class Long private extends AnyVal { */ def >>(x: Int): Long /** - * Returns this value bit-shifted left by the specified number of bits, - * filling in the right bits with the same value as the left-most bit of this. + * Returns this value bit-shifted right by the specified number of bits, + * filling in the left bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ * -21 >> 3 == -3 diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala index 36b9ec4df9..2cbbf3cc59 100644 --- a/src/library/scala/Short.scala +++ b/src/library/scala/Short.scala @@ -79,8 +79,8 @@ final abstract class Short private extends AnyVal { */ def >>>(x: Long): Int /** - * Returns this value bit-shifted left by the specified number of bits, - * filling in the right bits with the same value as the left-most bit of this. + * Returns this value bit-shifted right by the specified number of bits, + * filling in the left bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ * -21 >> 3 == -3 @@ -90,8 +90,8 @@ final abstract class Short private extends AnyVal { */ def >>(x: Int): Int /** - * Returns this value bit-shifted left by the specified number of bits, - * filling in the right bits with the same value as the left-most bit of this. + * Returns this value bit-shifted right by the specified number of bits, + * filling in the left bits with the same value as the left-most bit of this. * The effect of this is to retain the sign of the value. * @example {{{ * -21 >> 3 == -3 diff --git a/src/library/scala/collection/JavaConverters.scala b/src/library/scala/collection/JavaConverters.scala index 875f6e1c02..86e86d4584 100644 --- a/src/library/scala/collection/JavaConverters.scala +++ b/src/library/scala/collection/JavaConverters.scala @@ -52,7 +52,10 @@ import convert._ * - `scala.collection.Set` => `java.util.Set` * - `scala.collection.Map` => `java.util.Map` * - * @author Martin Odersky + * The following one way conversion is provided via `asScala`: + * + * - `java.util.Properties` => `scala.collection.mutable.Map` + * * @since 2.8.1 */ object JavaConverters extends DecorateAsJava with DecorateAsScala diff --git a/src/library/scala/collection/Searching.scala b/src/library/scala/collection/Searching.scala index b68124b3f8..25e8b5e253 100644 --- a/src/library/scala/collection/Searching.scala +++ b/src/library/scala/collection/Searching.scala @@ -36,12 +36,12 @@ object Searching { class SearchImpl[A, Repr](val coll: SeqLike[A, Repr]) { /** Search the sorted sequence for a specific element. If the sequence is an - * `IndexedSeq`, a binary search is used. Otherwise, a linear search is used. + * `IndexedSeqLike`, a binary search is used. Otherwise, a linear search is used. * * The sequence should be sorted with the same `Ordering` before calling; otherwise, * the results are undefined. * - * @see [[scala.collection.IndexedSeq]] + * @see [[scala.collection.IndexedSeqLike]] * @see [[scala.math.Ordering]] * @see [[scala.collection.SeqLike]], method `sorted` * @@ -54,18 +54,18 @@ object Searching { */ final def search[B >: A](elem: B)(implicit ord: Ordering[B]): SearchResult = coll match { - case _: IndexedSeq[A] => binarySearch(elem, 0, coll.length)(ord) + case _: IndexedSeqLike[A, Repr] => binarySearch(elem, 0, coll.length)(ord) case _ => linearSearch(coll.view, elem, 0)(ord) } /** Search within an interval in the sorted sequence for a specific element. If the - * sequence is an IndexedSeq, a binary search is used. Otherwise, a linear search + * sequence is an `IndexedSeqLike`, a binary search is used. Otherwise, a linear search * is used. * * The sequence should be sorted with the same `Ordering` before calling; otherwise, * the results are undefined. * - * @see [[scala.collection.IndexedSeq]] + * @see [[scala.collection.IndexedSeqLike]] * @see [[scala.math.Ordering]] * @see [[scala.collection.SeqLike]], method `sorted` * @@ -81,7 +81,7 @@ object Searching { final def search[B >: A](elem: B, from: Int, to: Int) (implicit ord: Ordering[B]): SearchResult = coll match { - case _: IndexedSeq[A] => binarySearch(elem, from, to)(ord) + case _: IndexedSeqLike[A, Repr] => binarySearch(elem, from, to)(ord) case _ => linearSearch(coll.view(from, to), elem, from)(ord) } diff --git a/src/library/scala/collection/convert/DecorateAsJava.scala b/src/library/scala/collection/convert/DecorateAsJava.scala index 6658b6feea..e6aa5da067 100644 --- a/src/library/scala/collection/convert/DecorateAsJava.scala +++ b/src/library/scala/collection/convert/DecorateAsJava.scala @@ -16,7 +16,7 @@ import WrapAsJava._ import scala.language.implicitConversions -/** A collection of decorators that allow to convert between +/** A collection of decorators that allow converting between * Scala and Java collections using `asScala` and `asJava` methods. * * The following conversions are supported via `asJava`, `asScala` @@ -38,8 +38,8 @@ import scala.language.implicitConversions * val sl2 : scala.collection.mutable.Buffer[Int] = jl.asScala * assert(sl eq sl2) * }}} - * The following conversions also are supported, but the - * direction Scala to Java is done my a more specifically named method: + * The following conversions are also supported, but the + * direction from Scala to Java is done by the more specifically named methods: * `asJavaCollection`, `asJavaEnumeration`, `asJavaDictionary`. * * - `scala.collection.Iterable` <=> `java.util.Collection` @@ -53,10 +53,12 @@ import scala.language.implicitConversions * - `scala.collection.Set` => `java.util.Set` * - `scala.collection.Map` => `java.util.Map` * - * @author Martin Odersky + * The following one way conversion is provided via `asScala`: + * + * - `java.util.Properties` => `scala.collection.mutable.Map` + * * @since 2.8.1 */ - trait DecorateAsJava { /** * Adds an `asJava` method that implicitly converts a Scala `Iterator` to a diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index cd2d3f843b..5a9734a99e 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -156,7 +156,7 @@ override def companion: GenericCompanion[Vector] = Vector override def take(n: Int): Vector[A] = { if (n <= 0) Vector.empty - else if (startIndex + n < endIndex) + else if (startIndex < endIndex - n) dropBack0(startIndex + n) else this @@ -165,7 +165,7 @@ override def companion: GenericCompanion[Vector] = Vector override def drop(n: Int): Vector[A] = { if (n <= 0) this - else if (startIndex + n < endIndex) + else if (startIndex < endIndex - n) dropFront0(startIndex + n) else Vector.empty diff --git a/src/library/scala/concurrent/duration/Duration.scala b/src/library/scala/concurrent/duration/Duration.scala index 8b7d81d1c4..a905ef345c 100644 --- a/src/library/scala/concurrent/duration/Duration.scala +++ b/src/library/scala/concurrent/duration/Duration.scala @@ -94,7 +94,7 @@ object Duration { timeUnitLabels flatMap { case (unit, names) => expandLabels(names) map (_ -> unit) } toMap /** - * Extract length and time unit out of a string, where the format must match the description for [[Duration$.apply(String):Duration apply(String)]]. + * Extract length and time unit out of a string, where the format must match the description for [[Duration$.apply(s:String)* apply(String)]]. * The extractor will not match for malformed strings or non-finite durations. */ def unapply(s: String): Option[(Long, TimeUnit)] = @@ -355,7 +355,7 @@ object Duration { * - isomorphic to `java.lang.Double` when it comes to infinite or undefined values * * The conversion between Duration and Double is done using [[Duration.toUnit]] (with unit NANOSECONDS) - * and [[Duration$.fromNanos(Double):Duration Duration.fromNanos(Double)]]. + * and [[Duration$.fromNanos(nanos:Double)* Duration.fromNanos(Double)]] * * <h2>Ordering</h2> * diff --git a/src/library/scala/math/package.scala b/src/library/scala/math/package.scala index b6593d6661..54c81ed613 100644 --- a/src/library/scala/math/package.scala +++ b/src/library/scala/math/package.scala @@ -58,7 +58,19 @@ package object math { * logarithms. */ def exp(x: Double): Double = java.lang.Math.exp(x) + + /** Returns the natural logarithm of a `double` value. + * + * @param x the number to take the natural logarithm of + * @return the value `logₑ(x)` where `e` is Eulers number + */ def log(x: Double): Double = java.lang.Math.log(x) + + /** Returns the square root of a `double` value. + * + * @param x the number to take the square root of + * @return the value √x + */ def sqrt(x: Double): Double = java.lang.Math.sqrt(x) def IEEEremainder(x: Double, y: Double): Double = java.lang.Math.IEEEremainder(x, y) diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 65740e87f1..5b613316cc 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -56,7 +56,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => new FreeTypeSymbol(name, origin) initFlags flags /** - * This map stores the original owner the the first time the owner of a symbol is re-assigned. + * This map stores the original owner the first time the owner of a symbol is re-assigned. * The original owner of a symbol is needed in some places in the backend. Ideally, owners should * be versioned like the type history. */ @@ -503,7 +503,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => case _ => new StubTermSymbol(this, name.toTermName, missingMessage) } - /** Given a field, construct a term symbol that represents the source construct that gave rise the the field */ + /** Given a field, construct a term symbol that represents the source construct that gave rise the field */ def sugaredSymbolOrSelf = { val getter = getterIn(owner) if (getter == NoSymbol) { diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala index 05724a879a..8fe1415d05 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala @@ -140,7 +140,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp if (tpl.linearizationTemplates.isEmpty && tpl.conversions.isEmpty) NodeSeq.Empty else - <li class="inherit out"><span>By inheritance</span></li> + <li class="inherit out"><span>By Inheritance</span></li> } </ol> </div> @@ -176,7 +176,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp <span class="filtertype"></span> <ol> <li class="hideall out"><span>Hide All</span></li> - <li class="showall in"><span>Show all</span></li> + <li class="showall in"><span>Show All</span></li> </ol> </div> } diff --git a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala index 093899231e..86900f26c9 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala @@ -248,7 +248,7 @@ trait DiagramFactory extends DiagramDirectiveParser { case _ => Nil }) - // Only show the the non-isolated nodes + // Only show the non-isolated nodes // TODO: Decide if we really want to hide package members, I'm not sure that's a good idea (!!!) // TODO: Does .distinct cause any stability issues? val sourceNodes = edges.map(_._1) |