summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/01-lexical-syntax.md10
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Reporting.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala9
-rw-r--r--src/compiler/scala/tools/nsc/settings/Warnings.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Delambdafy.scala1
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala6
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala2
-rw-r--r--src/library/scala/collection/GenTraversableLike.scala12
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala86
-rw-r--r--src/library/scala/collection/TraversableLike.scala36
-rw-r--r--src/library/scala/collection/immutable/PagedSeq.scala3
-rw-r--r--src/library/scala/collection/mutable/SetLike.scala4
-rw-r--r--src/library/scala/collection/package.scala38
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala1
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala4
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/Settings.scala2
-rw-r--r--test/disabled/presentation/akka/src/akka/actor/Supervisor.scala2
-rw-r--r--test/files/neg/macro-without-xmacros-a.check2
-rw-r--r--test/files/neg/macro-without-xmacros-b.check2
-rw-r--r--test/files/neg/t6040.check2
-rw-r--r--test/files/neg/t6120.check2
-rw-r--r--test/files/neg/t6952.check2
-rw-r--r--test/files/neg/t8736-c.check2
-rw-r--r--test/files/run/t3647.check1
-rw-r--r--test/junit/scala/collection/mutable/SetLikeTest.scala26
-rw-r--r--test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala73
-rw-r--r--test/scaladoc/resources/links.scala2
-rw-r--r--test/scaladoc/run/links.scala2
29 files changed, 219 insertions, 119 deletions
diff --git a/spec/01-lexical-syntax.md b/spec/01-lexical-syntax.md
index b26e5b2328..53c8caf745 100644
--- a/spec/01-lexical-syntax.md
+++ b/spec/01-lexical-syntax.md
@@ -90,11 +90,11 @@ syntactic class `id` of lexical identifiers.
abstract case catch class def
do else extends false final
finally for forSome if implicit
-import lazy match new null
-object override package private protected
-return sealed super this throw
-trait try true type val
-var while with yield
+import lazy macro match new
+null object override package private
+protected return sealed super this
+throw trait try true type
+val var while with yield
_ : = => <- <: <% >: # @
```
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 936bed7c8f..a618b080c8 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -231,7 +231,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
/** Called from parser, which signals hereby that a method definition has been parsed. */
def signalParseProgress(pos: Position) {}
- /** Called by ScalaDocAnalyzer when a doc comment has been parsed. */
+ /** Called by ScaladocAnalyzer when a doc comment has been parsed. */
def signalParsedDocComment(comment: String, pos: Position) = {
// TODO: this is all very broken (only works for scaladoc comments, not regular ones)
// --> add hooks to parser and refactor Interactive global to handle comments directly
diff --git a/src/compiler/scala/tools/nsc/Reporting.scala b/src/compiler/scala/tools/nsc/Reporting.scala
index 4e7a527a5a..e01c536ad1 100644
--- a/src/compiler/scala/tools/nsc/Reporting.scala
+++ b/src/compiler/scala/tools/nsc/Reporting.scala
@@ -78,7 +78,7 @@ trait Reporting extends scala.reflect.internal.Reporting { self: ast.Positions w
s"""|
|This can be achieved by adding the import clause 'import $fqname'
|or by setting the compiler option -language:$featureName.
- |See the Scala docs for value $fqname for a discussion
+ |See the Scaladoc for value $fqname for a discussion
|why the feature $req be explicitly enabled.""".stripMargin
)
reportedFeature += featureTrait
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
index 65a6b82570..1b97681743 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
@@ -35,15 +35,14 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
/*
* must-single-thread
*/
- def getOutFolder(csym: Symbol, cName: String, cunit: CompilationUnit): _root_.scala.tools.nsc.io.AbstractFile = {
- try {
+ def getOutFolder(csym: Symbol, cName: String, cunit: CompilationUnit): _root_.scala.tools.nsc.io.AbstractFile =
+ _root_.scala.util.Try {
outputDirectory(csym)
- } catch {
+ }.recover {
case ex: Throwable =>
reporter.error(cunit.body.pos, s"Couldn't create file for class $cName\n${ex.getMessage}")
null
- }
- }
+ }.get
var pickledBytes = 0 // statistics
diff --git a/src/compiler/scala/tools/nsc/settings/Warnings.scala b/src/compiler/scala/tools/nsc/settings/Warnings.scala
index 59cc13c64e..f570037760 100644
--- a/src/compiler/scala/tools/nsc/settings/Warnings.scala
+++ b/src/compiler/scala/tools/nsc/settings/Warnings.scala
@@ -49,7 +49,7 @@ trait Warnings {
val NullaryOverride = LintWarning("nullary-override", "Warn when non-nullary `def f()' overrides nullary `def f'.", true)
val InferAny = LintWarning("infer-any", "Warn when a type argument is inferred to be `Any`.", true)
val MissingInterpolator = LintWarning("missing-interpolator", "A string literal appears to be missing an interpolator id.")
- val DocDetached = LintWarning("doc-detached", "A ScalaDoc comment appears to be detached from its element.")
+ val DocDetached = LintWarning("doc-detached", "A Scaladoc comment appears to be detached from its element.")
val PrivateShadow = LintWarning("private-shadow", "A private field (or class parameter) shadows a superclass field.")
val TypeParameterShadow = LintWarning("type-parameter-shadow", "A local type parameter shadows a type already in scope.")
val PolyImplicitOverload = LintWarning("poly-implicit-overload", "Parameterized overloaded implicit methods are not visible as view bounds.")
diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
index ea8c1cbaf6..8e323de623 100644
--- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
+++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
@@ -294,6 +294,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
val name = unit.freshTypeName(s"$oldClassPart$suffix".replace("$anon", "$nestedInAnon"))
val lambdaClass = pkg newClassSymbol(name, originalFunction.pos, FINAL | SYNTHETIC) addAnnotation SerialVersionUIDAnnotation
+ lambdaClass.associatedFile = unit.source.file
// make sure currentRun.compiles(lambdaClass) is true (AddInterfaces does the same for trait impl classes)
currentRun.symSource(lambdaClass) = funOwner.sourceFile
lambdaClass setInfo ClassInfoType(parents, newScope, lambdaClass)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 494e1e49b7..509ce59104 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -588,10 +588,10 @@ trait Implicits {
if (Statistics.canEnable) Statistics.incCounter(matchingImplicits)
// workaround for deficient context provided by ModelFactoryImplicitSupport#makeImplicitConstraints
- val isScalaDoc = context.tree == EmptyTree
+ val isScaladoc = context.tree == EmptyTree
val itree0 = atPos(pos.focus) {
- if (isLocalToCallsite && !isScalaDoc) {
+ if (isLocalToCallsite && !isScaladoc) {
// SI-4270 SI-5376 Always use an unattributed Ident for implicits in the local scope,
// rather than an attributed Select, to detect shadowing.
Ident(info.name)
@@ -628,7 +628,7 @@ trait Implicits {
// for instance, if we have `class C[T]` and `implicit def conv[T: Numeric](c: C[T]) = ???`
// then Scaladoc will give us something of type `C[T]`, and it would like to know
// that `conv` is potentially available under such and such conditions
- case tree if isImplicitMethodType(tree.tpe) && !isScalaDoc =>
+ case tree if isImplicitMethodType(tree.tpe) && !isScaladoc =>
applyImplicitArgs(tree)
case tree => tree
}
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index 6600fea2d8..27a02c46a2 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -80,7 +80,7 @@ trait InteractiveAnalyzer extends Analyzer {
val existingDerivedSym = owningInfo.decl(sym.name.toTermName).filter(sym => sym.isSynthetic && sym.isMethod)
existingDerivedSym.alternatives foreach (owningInfo.decls.unlink)
val defTree = tree match {
- case dd: DocDef => dd.definition // See SI-9011, Scala IDE's presentation compiler incorporates ScalaDocGlobal with InterativeGlobal, so we have to unwrap DocDefs.
+ case dd: DocDef => dd.definition // See SI-9011, Scala IDE's presentation compiler incorporates ScaladocGlobal with InteractiveGlobal, so we have to unwrap DocDefs.
case _ => tree
}
enterImplicitWrapper(defTree.asInstanceOf[ClassDef])
diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala
index 479a8b5b1b..d730996be2 100644
--- a/src/library/scala/collection/GenTraversableLike.scala
+++ b/src/library/scala/collection/GenTraversableLike.scala
@@ -158,18 +158,6 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with
@migration("The behavior of `scanRight` has changed. The previous behavior can be reproduced with scanRight.reverse.", "2.9.0")
def scanRight[B, That](z: B)(op: (A, B) => B)(implicit bf: CanBuildFrom[Repr, B, That]): That
- /** Applies a function `f` to all elements of this $coll.
- *
- * @param f the function that is applied for its side-effect to every element.
- * The result of function `f` is discarded.
- *
- * @tparam U the type parameter describing the result of function `f`.
- * This result will always be ignored. Typically `U` is `Unit`,
- * but this is not necessary.
- *
- * @usecase def foreach(f: A => Unit): Unit
- * @inheritdoc
- */
def foreach[U](f: A => U): Unit
/** Builds a new collection by applying a function to all elements of this $coll.
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index a45ec965f5..244ff26397 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -49,6 +49,22 @@ import scala.language.higherKinds
*/
trait GenTraversableOnce[+A] extends Any {
+ /** Applies a function `f` to all elements of this $coll.
+ *
+ * @param f the function that is applied for its side-effect to every element.
+ * The result of function `f` is discarded.
+ *
+ * @tparam U the type parameter describing the result of function `f`.
+ * This result will always be ignored. Typically `U` is `Unit`,
+ * but this is not necessary.
+ *
+ * @usecase def foreach(f: A => Unit): Unit
+ * @inheritdoc
+ *
+ * Note: this method underlies the implementation of most other bulk operations.
+ * It's important to implement this method in an efficient way.
+ *
+ */
def foreach[U](f: A => U): Unit
def hasDefiniteSize: Boolean
@@ -110,13 +126,14 @@ trait GenTraversableOnce[+A] extends Any {
* binary operator.
*
* $undefinedorder
+ * $willNotTerminateInf
*
* @tparam A1 a type parameter for the binary operator, a supertype of `A`.
* @param z a neutral element for the fold operation; may be added to the result
* an arbitrary number of times, and must not change the result (e.g., `Nil` for list concatenation,
- * 0 for addition, or 1 for multiplication.)
- * @param op a binary operator that must be associative
- * @return the result of applying fold operator `op` between all the elements and `z`
+ * 0 for addition, or 1 for multiplication).
+ * @param op a binary operator that must be associative.
+ * @return the result of applying the fold operator `op` between all the elements and `z`, or `z` if this $coll is empty.
*/
def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1
@@ -205,6 +222,7 @@ trait GenTraversableOnce[+A] extends Any {
* op(...op(z, x_1), x_2, ..., x_n)
* }}}
* where `x,,1,,, ..., x,,n,,` are the elements of this $coll.
+ * Returns `z` if this $coll is empty.
*/
def foldLeft[B](z: B)(op: (B, A) => B): B
@@ -222,30 +240,32 @@ trait GenTraversableOnce[+A] extends Any {
* op(x_1, op(x_2, ... op(x_n, z)...))
* }}}
* where `x,,1,,, ..., x,,n,,` are the elements of this $coll.
+ * Returns `z` if this $coll is empty.
*/
def foldRight[B](z: B)(op: (A, B) => B): B
/** Aggregates the results of applying an operator to subsequent elements.
*
- * This is a more general form of `fold` and `reduce`. It has similar
- * semantics, but does not require the result to be a supertype of the
- * element type. It traverses the elements in different partitions
- * sequentially, using `seqop` to update the result, and then applies
- * `combop` to results from different partitions. The implementation of
- * this operation may operate on an arbitrary number of collection
- * partitions, so `combop` may be invoked an arbitrary number of times.
- *
- * For example, one might want to process some elements and then produce
- * a `Set`. In this case, `seqop` would process an element and append it
- * to the list, while `combop` would concatenate two lists from different
- * partitions together. The initial value `z` would be an empty set.
+ * This is a more general form of `fold` and `reduce`. It is similar to
+ * `foldLeft` in that it doesn't require the result to be a supertype of the
+ * element type. In addition, it allows parallel collections to be processed
+ * in chunks, and then combines the intermediate results.
+ *
+ * `aggregate` splits the $coll into partitions and processes each
+ * partition by sequentially applying `seqop`, starting with `z` (like
+ * `foldLeft`). Those intermediate results are then combined by using
+ * `combop` (like `fold`). The implementation of this operation may operate
+ * on an arbitrary number of collection partitions (even 1), so `combop` may
+ * be invoked an arbitrary number of times (even 0).
+ *
+ * As an example, consider summing up the integer values of a list of chars.
+ * The initial value for the sum is 0. First, `seqop` transforms each input
+ * character to an Int and adds it to the sum (of the partition). Then,
+ * `combop` just needs to sum up the intermediate results of the partitions:
* {{{
- * pc.aggregate(Set[Int]())(_ += process(_), _ ++ _)
+ * List('a', 'b', 'c').aggregate(0)({ (sum, ch) => sum + ch.toInt }, { (p1, p2) => p1 + p2 })
* }}}
*
- * Another example is calculating geometric mean from a collection of doubles
- * (one would typically require big doubles for this).
- *
* @tparam B the type of accumulated results
* @param z the initial value for the accumulated result of the partition - this
* will typically be the neutral element for the `seqop` operator (e.g.
@@ -423,13 +443,13 @@ trait GenTraversableOnce[+A] extends Any {
*/
def find(@deprecatedName('pred) p: A => Boolean): Option[A]
- /** Copies values of this $coll to an array.
+ /** Copies the elements of this $coll to an array.
* Fills the given array `xs` with values of this $coll.
* Copying will stop once either the end of the current $coll is reached,
- * or the end of the array is reached.
+ * or the end of the target array is reached.
*
* @param xs the array to fill.
- * @tparam B the type of the elements of the array.
+ * @tparam B the type of the elements of the target array.
*
* @usecase def copyToArray(xs: Array[A]): Unit
* @inheritdoc
@@ -438,14 +458,14 @@ trait GenTraversableOnce[+A] extends Any {
*/
def copyToArray[B >: A](xs: Array[B]): Unit
- /** Copies values of this $coll to an array.
+ /** Copies the elements of this $coll to an array.
* Fills the given array `xs` with values of this $coll, beginning at index `start`.
* Copying will stop once either the end of the current $coll is reached,
- * or the end of the array is reached.
+ * or the end of the target array is reached.
*
* @param xs the array to fill.
* @param start the starting index.
- * @tparam B the type of the elements of the array.
+ * @tparam B the type of the elements of the target array.
*
* @usecase def copyToArray(xs: Array[A], start: Int): Unit
* @inheritdoc
@@ -454,6 +474,22 @@ trait GenTraversableOnce[+A] extends Any {
*/
def copyToArray[B >: A](xs: Array[B], start: Int): Unit
+ /** Copies the elements of this $coll to an array.
+ * Fills the given array `xs` with at most `len` elements of
+ * this $coll, starting at position `start`.
+ * Copying will stop once either the end of the current $coll is reached,
+ * or the end of the target array is reached, or `len` elements have been copied.
+ *
+ * @param xs the array to fill.
+ * @param start the starting index.
+ * @param len the maximal number of elements to copy.
+ * @tparam B the type of the elements of the target array.
+ *
+ * @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
+ * @inheritdoc
+ *
+ * $willNotTerminateInf
+ */
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit
/** Displays all elements of this $coll in a string using start, end, and
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala
index 04ae8c8aff..bd1be84e97 100644
--- a/src/library/scala/collection/TraversableLike.scala
+++ b/src/library/scala/collection/TraversableLike.scala
@@ -340,14 +340,6 @@ trait TraversableLike[+A, +Repr] extends Any
b.result
}
- /** Tests whether a predicate holds for all elements of this $coll.
- *
- * $mayNotTerminateInf
- *
- * @param p the predicate used to test elements.
- * @return `true` if this $coll is empty, otherwise `true` if the given predicate `p`
- * holds for all elements of this $coll, otherwise `false`.
- */
def forall(p: A => Boolean): Boolean = {
var result = true
breakable {
@@ -374,15 +366,6 @@ trait TraversableLike[+A, +Repr] extends Any
result
}
- /** Finds the first element of the $coll satisfying a predicate, if any.
- *
- * $mayNotTerminateInf
- * $orderDependent
- *
- * @param p the predicate used to test elements.
- * @return an option value containing the first element in the $coll
- * that satisfies `p`, or `None` if none exists.
- */
def find(p: A => Boolean): Option[A] = {
var result: Option[A] = None
breakable {
@@ -594,23 +577,6 @@ trait TraversableLike[+A, +Repr] extends Any
*/
def inits: Iterator[Repr] = iterateUntilEmpty(_.init)
- /** Copies elements of this $coll to an array.
- * Fills the given array `xs` with at most `len` elements of
- * this $coll, starting at position `start`.
- * Copying will stop once either the end of the current $coll is reached,
- * or the end of the array is reached, or `len` elements have been copied.
- *
- * @param xs the array to fill.
- * @param start the starting index.
- * @param len the maximal number of elements to copy.
- * @tparam B the type of the elements of the array.
- *
- *
- * @usecase def copyToArray(xs: Array[A], start: Int, len: Int): Unit
- * @inheritdoc
- *
- * $willNotTerminateInf
- */
def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
var i = start
val end = (start + len) min xs.length
@@ -625,7 +591,7 @@ trait TraversableLike[+A, +Repr] extends Any
@deprecatedOverriding("Enforce contract of toTraversable that if it is Traversable it returns itself.", "2.11.0")
def toTraversable: Traversable[A] = thisCollection
-
+
def toIterator: Iterator[A] = toStream.iterator
def toStream: Stream[A] = toBuffer.toStream
// Override to provide size hint.
diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala
index a86d4b6746..982c10687c 100644
--- a/src/library/scala/collection/immutable/PagedSeq.scala
+++ b/src/library/scala/collection/immutable/PagedSeq.scala
@@ -23,6 +23,7 @@ import scala.reflect.ClassTag
* `fromIterator` and `fromIterable` provide generalised instances of `PagedSeq`
* @since 2.7
*/
+@deprecated("This object will be moved to the scala-parser-combinators module", "2.11.8")
object PagedSeq {
final val UndeterminedEnd = Int.MaxValue
@@ -126,7 +127,7 @@ import PagedSeq._
* @define mayNotTerminateInf
* @define willNotTerminateInf
*/
-@deprecatedInheritance("The implementation details of paged sequences make inheriting from them unwise.", "2.11.0")
+@deprecated("This class will be moved to the scala-parser-combinators module", "2.11.8")
class PagedSeq[T: ClassTag] protected(
more: (Array[T], Int, Int) => Int,
first1: Page[T],
diff --git a/src/library/scala/collection/mutable/SetLike.scala b/src/library/scala/collection/mutable/SetLike.scala
index 81a71adc91..01075a2633 100644
--- a/src/library/scala/collection/mutable/SetLike.scala
+++ b/src/library/scala/collection/mutable/SetLike.scala
@@ -129,7 +129,9 @@ trait SetLike[A, +This <: SetLike[A, This] with Set[A]]
/** Removes all elements from the set. After this operation is completed,
* the set will be empty.
*/
- def clear() { foreach(-=) }
+ def clear(): Unit =
+ for (elem <- this.toList)
+ this -= elem
override def clone(): This = empty ++= repr.seq
diff --git a/src/library/scala/collection/package.scala b/src/library/scala/collection/package.scala
index 13fe7a79c4..856f901b77 100644
--- a/src/library/scala/collection/package.scala
+++ b/src/library/scala/collection/package.scala
@@ -13,8 +13,11 @@ package scala
*
* == Guide ==
*
- * A detailed guide for the collections library is available
+ * A detailed guide for using the collections library is available
* at [[http://docs.scala-lang.org/overviews/collections/introduction.html]].
+ * Developers looking to extend the collections library can find a description
+ * of its architecture at
+ * [[http://docs.scala-lang.org/overviews/core/architecture-of-scala-collections.html]].
*
* == Using Collections ==
*
@@ -31,24 +34,25 @@ package scala
* array: Array[Int] = Array(1, 2, 3, 4, 5, 6)
*
* scala> array map { _.toString }
- * res0: Array[java.lang.String] = Array(1, 2, 3, 4, 5, 6)
+ * res0: Array[String] = Array(1, 2, 3, 4, 5, 6)
*
* scala> val list = List(1,2,3,4,5,6)
* list: List[Int] = List(1, 2, 3, 4, 5, 6)
*
* scala> list map { _.toString }
- * res1: List[java.lang.String] = List(1, 2, 3, 4, 5, 6)
+ * res1: List[String] = List(1, 2, 3, 4, 5, 6)
*
* }}}
*
* == Creating Collections ==
*
- * The most common way to create a collection is to use the companion objects as factories.
- * Of these, the three most common
- * are [[scala.collection.Seq]], [[scala.collection.immutable.Set]], and [[scala.collection.immutable.Map]]. Their
- * companion objects are all available
- * as type aliases the either the [[scala]] package or in `scala.Predef`, and can be used
- * like so:
+ * The most common way to create a collection is to use its companion object as
+ * a factory. The three most commonly used collections are
+ * [[scala.collection.Seq]], [[scala.collection.immutable.Set]], and
+ * [[scala.collection.immutable.Map]].
+ * They can be used directly as shown below since their companion objects are
+ * all available as type aliases in either the [[scala]] package or in
+ * `scala.Predef`. New collections are created like this:
* {{{
* scala> val seq = Seq(1,2,3,4,1)
* seq: Seq[Int] = List(1, 2, 3, 4, 1)
@@ -56,12 +60,12 @@ package scala
* scala> val set = Set(1,2,3,4,1)
* set: scala.collection.immutable.Set[Int] = Set(1, 2, 3, 4)
*
- * scala> val map = Map(1 -> "one",2 -> "two", 3 -> "three",2 -> "too")
- * map: scala.collection.immutable.Map[Int,java.lang.String] = Map((1,one), (2,too), (3,three))
+ * scala> val map = Map(1 -> "one", 2 -> "two", 3 -> "three", 2 -> "too")
+ * map: scala.collection.immutable.Map[Int,String] = Map(1 -> one, 2 -> too, 3 -> three)
* }}}
*
- * It is also typical to use the [[scala.collection.immutable]] collections over those
- * in [[scala.collection.mutable]]; The types aliased in
+ * It is also typical to prefer the [[scala.collection.immutable]] collections
+ * over those in [[scala.collection.mutable]]; the types aliased in
* the `scala.Predef` object are the immutable versions.
*
* Also note that the collections library was carefully designed to include several implementations of
@@ -74,9 +78,13 @@ package scala
*
* === Converting between Java Collections ===
*
- * The `JavaConversions` object provides implicit defs that will allow mostly seamless integration
- * between Java Collections-based APIs and the Scala collections library.
+ * The [[scala.collection.JavaConversions]] object provides implicit defs that
+ * will allow mostly seamless integration between APIs using Java Collections
+ * and the Scala collections library.
*
+ * Alternatively the [[scala.collection.JavaConverters]] object provides a collection
+ * of decorators that allow converting between Scala and Java collections using `asScala`
+ * and `asJava` methods.
*/
package object collection {
import scala.collection.generic.CanBuildFrom
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index e7b022b895..8c9b959569 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -1499,5 +1499,4 @@ self: ParIterableLike[T, Repr, Sequential] =>
append(s)
}
})
-
}
diff --git a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala
index cbf8ff22ba..8ea8c4deff 100644
--- a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala
@@ -125,9 +125,9 @@ abstract class ScaladocSyntaxAnalyzer[G <: Global](val global: G) extends Syntax
} else if (in.ch == '*') {
docBuffer = null
in.next
- val scalaDoc = ("/**", "*/")
+ val scaladoc = ("/**", "*/")
if (in.ch == '*')
- docBuffer = new StringBuilder(scalaDoc._1)
+ docBuffer = new StringBuilder(scaladoc._1)
do {
do {
if (in.ch != '*' && in.ch != SU) {
diff --git a/src/scaladoc/scala/tools/nsc/doc/Settings.scala b/src/scaladoc/scala/tools/nsc/doc/Settings.scala
index 067b2b2c29..90efa4e595 100644
--- a/src/scaladoc/scala/tools/nsc/doc/Settings.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/Settings.scala
@@ -45,7 +45,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_))
val docfooter = StringSetting (
"-doc-footer",
"footer",
- "A footer on every ScalaDoc page, by default the EPFL/Typesafe copyright notice. Can be overridden with a custom footer.",
+ "A footer on every Scaladoc page, by default the EPFL/Typesafe copyright notice. Can be overridden with a custom footer.",
""
)
diff --git a/test/disabled/presentation/akka/src/akka/actor/Supervisor.scala b/test/disabled/presentation/akka/src/akka/actor/Supervisor.scala
index 4a1309faef..bec3c83f1a 100644
--- a/test/disabled/presentation/akka/src/akka/actor/Supervisor.scala
+++ b/test/disabled/presentation/akka/src/akka/actor/Supervisor.scala
@@ -95,7 +95,7 @@ case class SupervisorFactory(val config: SupervisorConfig) {
* wire the children together using 'link', 'spawnLink' etc. and set the 'trapExit' flag in the
* children that should trap error signals and trigger restart.
* <p/>
- * See the ScalaDoc for the SupervisorFactory for an example on how to declaratively wire up children.
+ * See the Scaladoc for the SupervisorFactory for an example on how to declaratively wire up children.
*
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/
diff --git a/test/files/neg/macro-without-xmacros-a.check b/test/files/neg/macro-without-xmacros-a.check
index ec194be3a9..65445d80dd 100644
--- a/test/files/neg/macro-without-xmacros-a.check
+++ b/test/files/neg/macro-without-xmacros-a.check
@@ -2,7 +2,7 @@ Macros_2.scala:5: error: macro definition needs to be enabled
by making the implicit value scala.language.experimental.macros visible.
This can be achieved by adding the import clause 'import scala.language.experimental.macros'
or by setting the compiler option -language:experimental.macros.
-See the Scala docs for value scala.language.experimental.macros for a discussion
+See the Scaladoc for value scala.language.experimental.macros for a discussion
why the feature needs to be explicitly enabled.
def foo(x: Int): Int = macro foo_impl
^
diff --git a/test/files/neg/macro-without-xmacros-b.check b/test/files/neg/macro-without-xmacros-b.check
index c97850f0a9..e3c1010d50 100644
--- a/test/files/neg/macro-without-xmacros-b.check
+++ b/test/files/neg/macro-without-xmacros-b.check
@@ -2,7 +2,7 @@ Macros_2.scala:3: error: macro definition needs to be enabled
by making the implicit value scala.language.experimental.macros visible.
This can be achieved by adding the import clause 'import scala.language.experimental.macros'
or by setting the compiler option -language:experimental.macros.
-See the Scala docs for value scala.language.experimental.macros for a discussion
+See the Scaladoc for value scala.language.experimental.macros for a discussion
why the feature needs to be explicitly enabled.
def foo(x: Int): Int = macro Impls.foo_impl
^
diff --git a/test/files/neg/t6040.check b/test/files/neg/t6040.check
index 16c90ede7e..350f796d18 100644
--- a/test/files/neg/t6040.check
+++ b/test/files/neg/t6040.check
@@ -2,7 +2,7 @@ t6040.scala:1: error: extension of type scala.Dynamic needs to be enabled
by making the implicit value scala.language.dynamics visible.
This can be achieved by adding the import clause 'import scala.language.dynamics'
or by setting the compiler option -language:dynamics.
-See the Scala docs for value scala.language.dynamics for a discussion
+See the Scaladoc for value scala.language.dynamics for a discussion
why the feature needs to be explicitly enabled.
class X extends Dynamic
^
diff --git a/test/files/neg/t6120.check b/test/files/neg/t6120.check
index a7d17e29cf..f432fde32f 100644
--- a/test/files/neg/t6120.check
+++ b/test/files/neg/t6120.check
@@ -2,7 +2,7 @@ t6120.scala:5: warning: postfix operator bippy should be enabled
by making the implicit value scala.language.postfixOps visible.
This can be achieved by adding the import clause 'import scala.language.postfixOps'
or by setting the compiler option -language:postfixOps.
-See the Scala docs for value scala.language.postfixOps for a discussion
+See the Scaladoc for value scala.language.postfixOps for a discussion
why the feature should be explicitly enabled.
def f = null == null bippy
^
diff --git a/test/files/neg/t6952.check b/test/files/neg/t6952.check
index 1a591d02c6..acee0e7d60 100644
--- a/test/files/neg/t6952.check
+++ b/test/files/neg/t6952.check
@@ -2,7 +2,7 @@ t6952.scala:2: error: extension of type scala.Dynamic needs to be enabled
by making the implicit value scala.language.dynamics visible.
This can be achieved by adding the import clause 'import scala.language.dynamics'
or by setting the compiler option -language:dynamics.
-See the Scala docs for value scala.language.dynamics for a discussion
+See the Scaladoc for value scala.language.dynamics for a discussion
why the feature needs to be explicitly enabled.
trait B extends Dynamic
^
diff --git a/test/files/neg/t8736-c.check b/test/files/neg/t8736-c.check
index 06b2228543..7debb6d515 100644
--- a/test/files/neg/t8736-c.check
+++ b/test/files/neg/t8736-c.check
@@ -2,7 +2,7 @@ t8736-c.scala:4: warning: higher-kinded type should be enabled
by making the implicit value scala.language.higherKinds visible.
This can be achieved by adding the import clause 'import scala.language.higherKinds'
or by setting the compiler option -language:higherKinds.
-See the Scala docs for value scala.language.higherKinds for a discussion
+See the Scaladoc for value scala.language.higherKinds for a discussion
why the feature should be explicitly enabled.
def hk[M[_]] = ???
^
diff --git a/test/files/run/t3647.check b/test/files/run/t3647.check
new file mode 100644
index 0000000000..e5c1ee1701
--- /dev/null
+++ b/test/files/run/t3647.check
@@ -0,0 +1 @@
+warning: there were three deprecation warnings; re-run with -deprecation for details
diff --git a/test/junit/scala/collection/mutable/SetLikeTest.scala b/test/junit/scala/collection/mutable/SetLikeTest.scala
new file mode 100644
index 0000000000..c819024558
--- /dev/null
+++ b/test/junit/scala/collection/mutable/SetLikeTest.scala
@@ -0,0 +1,26 @@
+package scala.collection.mutable
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class SetLikeTest {
+
+ class MySet(self: Set[String]) extends Set[String] with SetLike[String, MySet] {
+ override def -=(elem: String) = { self -= elem; this }
+ override def +=(elem: String) = { self += elem; this }
+
+ override def empty = new MySet(self.empty)
+ override def iterator = self.iterator
+ override def contains(elem: String) = self.contains(elem)
+ }
+
+ @Test
+ def hasCorrectClear() {
+ val s = new MySet(Set("EXPOSEDNODE", "CONNECTABLE"))
+ s.clear()
+ assertEquals(new MySet(Set()), s)
+ }
+}
diff --git a/test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala b/test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala
new file mode 100644
index 0000000000..010078e28a
--- /dev/null
+++ b/test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala
@@ -0,0 +1,73 @@
+package scala.tools.nsc.transform.delambdafy
+
+import scala.reflect.io.Path.jfile2path
+import scala.tools.nsc.backend.jvm.CodeGenTools.getGeneratedClassfiles
+import scala.tools.nsc.backend.jvm.CodeGenTools.makeSourceFile
+import scala.tools.nsc.backend.jvm.CodeGenTools.newCompilerWithoutVirtualOutdir
+import scala.tools.nsc.io.AbstractFile
+import scala.tools.testing.TempDir
+
+import org.junit.Assert.assertTrue
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(classOf[JUnit4])
+class DelambdafyTest {
+ def compileToMultipleOutputWithDelamdbafyMethod(): List[(String, Array[Byte])] = {
+ val codeForMultiOutput = """
+object Delambdafy {
+ type -->[D, I] = PartialFunction[D, I]
+
+ def main(args: Array[String]): Unit = {
+ val result = List(1, 2, 4).map { a =>
+ val list = List("1", "2", "3").map { _ + "test" }
+ list.find { _ == a.toString + "test" }
+ }
+ println(result)
+ lazy val _foo = foo(result) {
+ case x :: xs if x isDefined => x.get.length
+ case _ => 0
+ }
+ println(_foo)
+ lazy val bar: Int => Int = {
+ case 2 => 23
+ case _ =>
+ val v = List(1).map { _ + 42 }.head
+ v + 31
+ }
+ bar(3)
+ lazy val _baz = baz {
+ case 1 =>
+ val local = List(1).map(_ + 1)
+ local.head
+ }
+ }
+
+ def baz[T](f: Any --> Any): Any => Any = f
+
+ def foo(b: List[Option[String]])(a: List[Option[String]] => Int): Int = a(b)
+}
+"""
+ val srcFile = makeSourceFile(codeForMultiOutput, "delambdafyTest.scala")
+ val outDir = AbstractFile.getDirectory(TempDir.createTempDir())
+ val outDirPath = outDir.canonicalPath
+ val extraArgs = "-Ybackend:GenBCode -Ydelambdafy:method"
+ val argsWithOutDir = extraArgs + s" -d $outDirPath -cp $outDirPath"
+ val compiler = newCompilerWithoutVirtualOutdir(extraArgs = argsWithOutDir)
+ compiler.settings.outputDirs.add(srcFile.file, outDir)
+
+ new compiler.Run().compileSources(List(srcFile))
+
+ val classfiles = getGeneratedClassfiles(outDir)
+ outDir.delete()
+ classfiles
+ }
+
+ @Test
+ def shouldFindOutputFoldersForAllPromotedLambdasAsMethod(): Unit = {
+ val actual = compileToMultipleOutputWithDelamdbafyMethod()
+
+ assertTrue(actual.length > 0)
+ }
+}
diff --git a/test/scaladoc/resources/links.scala b/test/scaladoc/resources/links.scala
index ecac9c63cf..8e000ab979 100644
--- a/test/scaladoc/resources/links.scala
+++ b/test/scaladoc/resources/links.scala
@@ -1,6 +1,6 @@
// that would be:
// SI-5079 "Scaladoc can't link to an object (only a class or trait)"
-// SI-4497 "Links in ScalaDoc - Spec and implementation unsufficient"
+// SI-4497 "Links in Scaladoc - Spec and implementation unsufficient"
// SI-4224 "Wiki-links should support method targets"
// SI-3695 "support non-fully-qualified type links in scaladoc comments"
// SI-6487 "Scaladoc can't link to inner classes"
diff --git a/test/scaladoc/run/links.scala b/test/scaladoc/run/links.scala
index 64441c2d95..01db66aec3 100644
--- a/test/scaladoc/run/links.scala
+++ b/test/scaladoc/run/links.scala
@@ -3,7 +3,7 @@ import scala.tools.nsc.doc.model._
import scala.tools.partest.ScaladocModelTest
// SI-5079 "Scaladoc can't link to an object (only a class or trait)"
-// SI-4497 "Links in ScalaDoc - Spec and implementation unsufficient"
+// SI-4497 "Links in Scaladoc - Spec and implementation unsufficient"
// SI-4224 "Wiki-links should support method targets"
// SI-3695 "support non-fully-qualified type links in scaladoc comments"
// SI-6487 "Scaladoc can't link to inner classes"