summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--CONTRIBUTING.md6
-rw-r--r--README.md58
-rw-r--r--build.sbt772
-rw-r--r--build.xml17
-rw-r--r--doc/LICENSE.md4
-rw-r--r--doc/License.rtf4
-rw-r--r--project/JarJar.scala92
-rw-r--r--project/Osgi.scala69
-rw-r--r--project/ParserUtil.scala52
-rw-r--r--project/PartestUtil.scala92
-rw-r--r--project/ScalaOptionParser.scala129
-rw-r--r--project/ScalaTool.scala21
-rw-r--r--project/ScriptCommands.scala19
-rw-r--r--project/VersionUtil.scala126
-rw-r--r--project/build.properties2
-rw-r--r--project/plugins.sbt6
-rw-r--r--scripts/common3
-rw-r--r--[-rwxr-xr-x]scripts/jobs/integrate/bootstrap34
-rwxr-xr-xscripts/jobs/integrate/windows15
-rwxr-xr-xscripts/jobs/validate/publish-core13
-rw-r--r--spec/01-lexical-syntax.md10
-rw-r--r--spec/06-expressions.md2
-rw-r--r--spec/07-implicits.md12
-rw-r--r--src/build/genprod.scala3
-rw-r--r--src/build/maven/scala-actors-pom.xml4
-rw-r--r--src/build/maven/scala-compiler-doc-pom.xml4
-rw-r--r--src/build/maven/scala-compiler-interactive-pom.xml4
-rw-r--r--src/build/maven/scala-compiler-pom.xml4
-rw-r--r--src/build/maven/scala-dist-pom.xml4
-rw-r--r--src/build/maven/scala-library-all-pom.xml4
-rw-r--r--src/build/maven/scala-library-pom.xml4
-rw-r--r--src/build/maven/scala-reflect-pom.xml4
-rw-r--r--src/build/maven/scalap-pom.xml4
-rw-r--r--src/compiler/scala/reflect/quasiquotes/Parsers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/GenericRunnerCommand.scala6
-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/ast/parser/Parsers.scala57
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala32
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala9
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/opt/BytecodeUtils.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala2
-rw-r--r--src/compiler/scala/tools/nsc/settings/Warnings.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Delambdafy.scala1
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/patmat/Logic.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala18
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/AnalyzerPlugins.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala29
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/PatternTypers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala66
-rw-r--r--src/eclipse/README.md17
-rw-r--r--src/eclipse/asm/.classpath6
-rw-r--r--src/eclipse/asm/.project29
-rw-r--r--src/eclipse/interactive/.classpath1
-rw-r--r--src/eclipse/interactive/.gitignore2
-rw-r--r--src/eclipse/partest/.classpath2
-rw-r--r--src/eclipse/partest/.gitignore2
-rw-r--r--src/eclipse/reflect/.gitignore2
-rw-r--r--src/eclipse/repl/.classpath16
-rw-r--r--src/eclipse/repl/.gitignore2
-rw-r--r--src/eclipse/scala-compiler/.classpath2
-rw-r--r--src/eclipse/scala-compiler/.gitignore2
-rw-r--r--src/eclipse/scala-library/.gitignore2
-rw-r--r--src/eclipse/scaladoc/.classpath2
-rw-r--r--src/eclipse/scaladoc/.gitignore2
-rw-r--r--src/eclipse/scalap/.gitignore2
-rw-r--r--src/eclipse/test-junit/.classpath6
-rw-r--r--src/eclipse/test-junit/.gitignore2
-rw-r--r--src/intellij/README12
-rw-r--r--src/intellij/README.md13
-rw-r--r--src/intellij/scala-build.iml.SAMPLE109
-rw-r--r--src/intellij/scala.ipr.SAMPLE3
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala2
-rw-r--r--src/library/scala/Byte.scala8
-rw-r--r--src/library/scala/Char.scala8
-rw-r--r--src/library/scala/Int.scala8
-rw-r--r--src/library/scala/Long.scala8
-rw-r--r--src/library/scala/Product1.scala2
-rw-r--r--src/library/scala/Product10.scala2
-rw-r--r--src/library/scala/Product11.scala2
-rw-r--r--src/library/scala/Product12.scala2
-rw-r--r--src/library/scala/Product13.scala2
-rw-r--r--src/library/scala/Product14.scala2
-rw-r--r--src/library/scala/Product15.scala2
-rw-r--r--src/library/scala/Product16.scala2
-rw-r--r--src/library/scala/Product17.scala2
-rw-r--r--src/library/scala/Product18.scala2
-rw-r--r--src/library/scala/Product19.scala2
-rw-r--r--src/library/scala/Product2.scala2
-rw-r--r--src/library/scala/Product20.scala2
-rw-r--r--src/library/scala/Product21.scala2
-rw-r--r--src/library/scala/Product22.scala2
-rw-r--r--src/library/scala/Product3.scala2
-rw-r--r--src/library/scala/Product4.scala2
-rw-r--r--src/library/scala/Product5.scala2
-rw-r--r--src/library/scala/Product6.scala2
-rw-r--r--src/library/scala/Product7.scala2
-rw-r--r--src/library/scala/Product8.scala2
-rw-r--r--src/library/scala/Product9.scala2
-rw-r--r--src/library/scala/Short.scala8
-rw-r--r--src/library/scala/collection/BitSetLike.scala2
-rw-r--r--src/library/scala/collection/GenMapLike.scala3
-rw-r--r--src/library/scala/collection/GenTraversableLike.scala20
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala129
-rw-r--r--src/library/scala/collection/Iterator.scala53
-rw-r--r--src/library/scala/collection/JavaConverters.scala5
-rw-r--r--src/library/scala/collection/LinearSeqOptimized.scala10
-rw-r--r--src/library/scala/collection/MapLike.scala8
-rw-r--r--src/library/scala/collection/Searching.scala12
-rw-r--r--src/library/scala/collection/Traversable.scala2
-rw-r--r--src/library/scala/collection/TraversableLike.scala49
-rw-r--r--src/library/scala/collection/TraversableOnce.scala20
-rw-r--r--src/library/scala/collection/TraversableProxyLike.scala2
-rw-r--r--src/library/scala/collection/convert/DecorateAsJava.scala12
-rw-r--r--src/library/scala/collection/generic/TraversableForwarder.scala2
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala4
-rw-r--r--src/library/scala/collection/immutable/HashSet.scala6
-rw-r--r--src/library/scala/collection/immutable/IntMap.scala2
-rw-r--r--src/library/scala/collection/immutable/List.scala26
-rw-r--r--src/library/scala/collection/immutable/LongMap.scala2
-rw-r--r--src/library/scala/collection/immutable/Map.scala8
-rw-r--r--src/library/scala/collection/immutable/PagedSeq.scala3
-rw-r--r--src/library/scala/collection/immutable/RedBlackTree.scala4
-rw-r--r--src/library/scala/collection/immutable/Set.scala74
-rw-r--r--src/library/scala/collection/immutable/Stream.scala8
-rw-r--r--src/library/scala/collection/immutable/TreeMap.scala2
-rw-r--r--src/library/scala/collection/immutable/TreeSet.scala2
-rw-r--r--src/library/scala/collection/immutable/Vector.scala6
-rw-r--r--src/library/scala/collection/mutable/AnyRefMap.scala116
-rw-r--r--src/library/scala/collection/mutable/ArraySeq.scala2
-rw-r--r--src/library/scala/collection/mutable/ArrayStack.scala2
-rw-r--r--src/library/scala/collection/mutable/HashMap.scala6
-rw-r--r--src/library/scala/collection/mutable/HashSet.scala2
-rw-r--r--src/library/scala/collection/mutable/ImmutableSetAdaptor.scala2
-rw-r--r--src/library/scala/collection/mutable/LinkedListLike.scala2
-rw-r--r--src/library/scala/collection/mutable/LongMap.scala122
-rw-r--r--src/library/scala/collection/mutable/OpenHashMap.scala19
-rw-r--r--src/library/scala/collection/mutable/SetLike.scala4
-rw-r--r--src/library/scala/collection/mutable/SynchronizedSet.scala2
-rw-r--r--src/library/scala/collection/package.scala38
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala19
-rw-r--r--src/library/scala/collection/parallel/ParMapLike.scala8
-rw-r--r--src/library/scala/concurrent/Future.scala2
-rw-r--r--src/library/scala/concurrent/duration/Duration.scala4
-rw-r--r--src/library/scala/math/package.scala12
-rw-r--r--src/library/scala/reflect/Manifest.scala3
-rw-r--r--src/library/scala/reflect/ScalaLongSignature.java2
-rw-r--r--src/library/scala/reflect/ScalaSignature.java2
-rw-r--r--src/library/scala/runtime/Tuple2Zipped.scala8
-rw-r--r--src/library/scala/runtime/Tuple3Zipped.scala8
-rw-r--r--src/library/scala/util/Either.scala12
-rw-r--r--src/library/scala/util/MurmurHash.scala2
-rw-r--r--src/library/scala/util/Properties.scala2
-rw-r--r--src/library/scala/util/hashing/MurmurHash3.scala2
-rw-r--r--src/manual/scala/man1/fsc.scala6
-rw-r--r--src/manual/scala/man1/scala.scala15
-rw-r--r--src/manual/scala/man1/scalac.scala6
-rw-r--r--src/manual/scala/tools/docutil/ManMaker.scala10
-rw-r--r--src/reflect/scala/reflect/api/Internals.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala42
-rw-r--r--src/reflect/scala/reflect/internal/Variances.scala24
-rw-r--r--src/reflect/scala/reflect/internal/tpe/TypeMaps.scala18
-rw-r--r--src/reflect/scala/reflect/internal/util/WeakHashSet.scala6
-rw-r--r--src/reflect/scala/reflect/macros/Attachments.scala2
-rw-r--r--src/reflect/scala/reflect/runtime/ReflectionUtils.scala4
-rw-r--r--src/reflect/scala/reflect/runtime/SynchronizedOps.scala4
-rw-r--r--src/repl/scala/tools/nsc/interpreter/ILoop.scala53
-rw-r--r--src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala2
-rw-r--r--src/repl/scala/tools/nsc/interpreter/JavapClass.scala4
-rw-r--r--src/repl/scala/tools/nsc/interpreter/ReplProps.scala2
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala4
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/Settings.scala43
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala34
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala6
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala10
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/html/resource/lib/jquery.layout.js6
-rw-r--r--src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala2
-rw-r--r--src/scalap/decoder.properties2
-rw-r--r--src/scalap/scala/tools/scalap/CodeWriter.scala2
-rw-r--r--src/scalap/scala/tools/scalap/Decode.scala2
-rw-r--r--src/scalap/scala/tools/scalap/JavaWriter.scala8
-rw-r--r--src/scalap/scala/tools/scalap/MetaParser.scala16
-rw-r--r--src/scalap/scala/tools/scalap/scalax/rules/Result.scala2
-rw-r--r--src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala6
-rw-r--r--test/disabled/presentation/akka/src/akka/actor/Supervisor.scala2
-rw-r--r--test/files/jvm/innerClassEnclMethodJavaReflection.scala9
-rw-r--r--test/files/neg/choices.check6
-rw-r--r--test/files/neg/depmet_1.check4
-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/partestInvalidFlag.check4
-rw-r--r--test/files/neg/partestInvalidFlag.flags1
-rw-r--r--test/files/neg/partestInvalidFlag.scala1
-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/neg/t9572.check7
-rw-r--r--test/files/neg/t9572.scala6
-rw-r--r--test/files/neg/warn-unused-imports.check46
-rw-r--r--test/files/neg/warn-unused-imports/sample_1.scala17
-rw-r--r--test/files/neg/warn-unused-imports/warn-unused-imports_2.scala (renamed from test/files/neg/warn-unused-imports.scala)30
-rw-r--r--test/files/pos/existental-slow-compile2.scala7
-rw-r--r--test/files/pos/existential-slow-compile1.flags1
-rw-r--r--test/files/pos/existential-slow-compile1.scala7
-rw-r--r--test/files/pos/t3420.flags2
-rw-r--r--test/files/presentation/doc/doc.scala6
-rw-r--r--test/files/run/repl-paste-5.check28
-rw-r--r--test/files/run/repl-paste-5.scala18
-rw-r--r--test/files/run/t3647.check1
-rw-r--r--test/files/run/t4950.check7
-rw-r--r--test/files/run/t4950.scala24
-rw-r--r--test/files/run/t7634.check4
-rw-r--r--test/files/run/t7634.scala2
-rw-r--r--test/files/run/t9546.scala13
-rw-r--r--test/files/run/t9546b.scala13
-rw-r--r--test/files/run/t9546c.scala13
-rw-r--r--test/files/run/t9546d.scala16
-rw-r--r--test/files/run/t9546e.scala15
-rw-r--r--test/files/run/t9567.scala18
-rw-r--r--test/files/run/t9567b.scala19
-rw-r--r--test/files/run/t9567c.scala29
-rw-r--r--test/junit/scala/collection/IteratorTest.scala28
-rw-r--r--test/junit/scala/collection/SearchingTest.scala48
-rw-r--r--test/junit/scala/collection/immutable/VectorTest.scala30
-rw-r--r--test/junit/scala/collection/mutable/OpenHashMapTest.scala42
-rw-r--r--test/junit/scala/collection/mutable/SetLikeTest.scala26
-rw-r--r--test/junit/scala/reflect/ClassTag.scala12
-rw-r--r--test/junit/scala/tools/nsc/transform/delambdafy/DelambdafyTest.scala73
-rwxr-xr-xtest/partest8
-rw-r--r--test/scaladoc/resources/links.scala2
-rw-r--r--test/scaladoc/run/links.scala2
-rw-r--r--test/scaladoc/run/tag-requirements.check16
-rw-r--r--test/scaladoc/run/tag-requirements.scala53
-rw-r--r--tools/get-scala-commit-date.bat4
-rw-r--r--tools/get-scala-commit-sha.bat4
-rwxr-xr-xtools/scaladoc-diff117
-rw-r--r--versions.properties2
243 files changed, 3132 insertions, 1117 deletions
diff --git a/.gitignore b/.gitignore
index d6571a377f..061cd274ac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,9 @@
/build.properties
/buildcharacter.properties
+# might get generated when testing Jenkins scripts locally
+/jenkins.properties
+
# target directories for ant build
/build/
/dists/
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d01a71b9bd..617734210f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,17 +4,17 @@ We follow the standard GitHub [fork & pull](https://help.github.com/articles/usi
You're always welcome to submit your PR straight away and start the discussion (without reading the rest of this wonderful doc, or the `READMEnot^H^H^H.md`). The goal of these notes is to make your experience contributing to Scala as smooth and pleasant as possible. We're happy to guide you through the process once you've submitted your PR.
## The Scala Community
-In 2014, you -- the Scala community -- matched the core team at EPFL in number of commits contributed to Scala 2.11, doubling the percentage of commits from outside EPFL/Typesafe since 2.10. Excellent work! (The split was roughly 25/25/50 for you/EPFL/Typesafe.)
+In 2014, you -- the Scala community -- matched the core team at EPFL in number of commits contributed to Scala 2.11, doubling the percentage of commits from outside EPFL/Lightbend since 2.10. Excellent work! (The split was roughly 25/25/50 for you/EPFL/Lightbend.)
We are super happy about this, and are eager to make your experience contributing to Scala productive and satisfying, so that we can keep up this growth. We can't do this alone (nor do we want to)!
This is why we're collecting these notes on how to contribute, and we hope you'll share your experience to improve the process for the next contributor! (Feel free to send a PR for this note, send your thoughts to scala-internals, or tweet about it to @adriaanm.)
-By the way, the team at Typesafe is: @adriaanm, @lrytz, @retronym, and @SethTisue.
+By the way, the team at Lightbend is: @adriaanm, @lrytz, @retronym, @SethTisue, and @szeiger.
## What kind of PR are you submitting?
-Regardless of the nature of your Pull Request, we have to ask you to digitally sign the [Scala CLA](http://typesafe.com/contribute/cla/scala), to protect the OSS nature of the code base.
+Regardless of the nature of your Pull Request, we have to ask you to digitally sign the [Scala CLA](http://www.lightbend.com/contribute/cla/scala), to protect the OSS nature of the code base.
You don't need to submit separate PRs for 2.11.x, 2.12.x, and 2.13.x. Any changes accepted on one of these branches will, in time, be merged into the later branches.
diff --git a/README.md b/README.md
index 1b4dbb03c2..64a09a4644 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,18 @@
# Welcome!
This is the official repository for the [Scala Programming Language](http://www.scala-lang.org).
-To contribute to the Scala Standard Library, Scala Compiler and Scala Language Specification, please send us a [pull request](https://help.github.com/articles/using-pull-requests/#fork--pull) from your fork of this repository! We do have to ask you to sign the [Scala CLA](http://typesafe.com/contribute/cla/scala) before we can merge any of your work into our code base, to protect its open source nature.
+# How to contribute
-For more information on building and developing the core of Scala, read on! Please also check out our [guidelines for contributing](CONTRIBUTING.md).
+To contribute to the Scala Standard Library, Scala Compiler and Scala Language Specification, please send us a [pull request](https://help.github.com/articles/using-pull-requests/#fork--pull) from your fork of this repository! We do have to ask you to sign the [Scala CLA](http://www.lightbend.com/contribute/cla/scala) before we can merge any of your work into our code base, to protect its open source nature.
+
+For more information on building and developing the core of Scala, read on!
+
+Please also check out:
+
+* our [guidelines for contributing](CONTRIBUTING.md).
+* the ["Scala Hacker Guide"](http://scala-lang.org/contribute/hacker-guide.html) covers some of the same ground as this README, but in greater detail and in a more tutorial style, using a running example.
+
+# Reporting issues
We're still using Jira for issue reporting, so please [report any issues](https://issues.scala-lang.org) over there.
(We would love to start using GitHub Issues, but we're too resource-constrained to take on this migration right now.)
@@ -14,7 +23,7 @@ If you need some help with your PR at any time, please feel free to @-mention an
| username | talk to me about... |
--------------------------------------------------------------------------------------------------|----------------------------------------------------------------|---------------------------------------------------|
<img src="https://avatars.githubusercontent.com/adriaanm" height="50px" title="Adriaan Moors"/> | [`@adriaanm`](https://github.com/adriaanm) | type checker, pattern matcher, infrastructure, language spec |
- <img src="https://avatars.githubusercontent.com/SethTisue" height="50px" title="Seth Tisue"/> | [`@SethTisue`](https://github.com/SethTisue) | back-end, library, the welcome-to-Scala experience, build |
+ <img src="https://avatars.githubusercontent.com/SethTisue" height="50px" title="Seth Tisue"/> | [`@SethTisue`](https://github.com/SethTisue) | build, developer docs, community build, Jenkins, library, the welcome-to-Scala experience |
<img src="https://avatars.githubusercontent.com/retronym" height="50px" title="Jason Zaugg"/> | [`@retronym`](https://github.com/retronym) | compiler performance, weird compiler bugs, Java 8 lambdas, REPL |
<img src="https://avatars.githubusercontent.com/Ichoran" height="50px" title="Rex Kerr"/> | [`@Ichoran`](https://github.com/Ichoran) | collections library, performance |
<img src="https://avatars.githubusercontent.com/lrytz" height="50px" title="Lukas Rytz"/> | [`@lrytz`](https://github.com/lrytz) | optimizer, named & default arguments |
@@ -31,16 +40,12 @@ P.S.: If you have some spare time to help out around here, we would be delighted
# Handy Links
- [A wealth of documentation](http://docs.scala-lang.org)
+ - [mailing lists](http://www.scala-lang.org/community/)
+ - [Gitter room for Scala contributors](https://gitter.im/scala/contributors)
- [Scala CI](https://scala-ci.typesafe.com/)
- - [Download the latest nightly](http://www.scala-lang.org/files/archive/nightly/2.11.x/)
- - [(Deprecated) Scala CI at EPFL](https://scala-webapps.epfl.ch/jenkins/)
- - Scala mailing lists:
- - [Compiler and standard library development](https://groups.google.com/group/scala-internals)
- - [Users of Scala](https://groups.google.com/group/scala-user)
- - [Scala language discussion](https://groups.google.com/group/scala-language)
- - [Scala Improvement Process](https://groups.google.com/group/scala-sips)
- - [Debate](https://groups.google.com/group/scala-debate)
- - [Announcements](https://groups.google.com/group/scala-announce)
+ - download the latest nightlies:
+ - [2.11.x](http://www.scala-lang.org/files/archive/nightly/2.11.x/)
+ - [2.12.x](http://www.scala-lang.org/files/archive/nightly/2.12.x/)
# Repository structure
@@ -65,7 +70,13 @@ scala/
## Requirements
-You'll need a Java SDK (6 or newer), Apache Ant (version 1.9.0 or above), and curl (for `./pull-binary-libs.sh`).
+You'll need a Java SDK. The baseline version is 6 for 2.11.x, 8 for
+2.12.x. (It's also possible to use a later SDK for local development,
+but the CI will verify against the baseline version.)
+
+You'll also need Apache Ant (version 1.9.0 or above) and curl (for `./pull-binary-libs.sh`).
+
+Mac OS X and Linux work. Windows may work if you use Cygwin. (Community help with keeping the build working on Windows is appreciated.)
## Git Hygiene
@@ -120,25 +131,10 @@ Here, `<milestone>` is the milestone targeted by the PR (e.g., 2.11.6), and `<sh
## IDE Setup
### Eclipse
-Download the [Scala IDE bundle](http://scala-ide.org/download/sdk.html). It comes preconfigured for optimal performance.
-
- - Run `ant init` to download some necessary jars.
- - Import the project (in `src/eclipse`) via `File` → `Import Existing Projects into Workspace`. Check all projects and click ok.
-
-For important details on building, debugging and file encodings, please see [the excellent tutorial on scala-ide.org](http://scala-ide.org/docs/tutorials/scalac-trunk/index.html) and the included README.md in src/eclipse.
-
-### IntelliJ 14
-Use the latest IntelliJ IDEA release and install the Scala plugin from within the IDE.
-
-The following steps are required to use IntelliJ IDEA on Scala trunk
- - Run `ant init`. This will download some JARs to `./build/deps`, which are included in IntelliJ's classpath.
- - Run `./src/intellij/setup.sh`.
- - Open `./src/intellij/scala.ipr` in IntelliJ.
- - `File` → `Project Structure` → `Project` → `Project SDK`. Create an SDK entry named "1.6" containing the Java 1.6 SDK.
- (You may use a later SDK for local development, but the CI will verify against Java 6.)
+See `src/eclipse/README.md`.
-Compilation within IDEA is performed in `-Dlocker.skip=1` mode: the sources are built
-directly using the STARR compiler (which is downloaded from [the Central Repository](http://central.sonatype.org/), according to `starr.version` in `versions.properties`).
+### IntelliJ 15
+See [src/intellij/README.md](src/intellij/README.md).
## Building with sbt (EXPERIMENTAL)
diff --git a/build.sbt b/build.sbt
index 8e79e1019f..b36f54ba99 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1,10 +1,13 @@
/*
* The new, sbt-based build definition for Scala.
*
- * What you see below is very much work-in-progress. Basics like compiling and packaging jars
- * (into right location) work. Everything else is missing:
- * building docs, placing shell scripts in right locations (so you can run compiler easily),
- * running partest test, compiling and running JUnit test, and many, many other things.
+ * What you see below is very much work-in-progress. The following features are implemented:
+ * - Compiling all classses for the compiler and library ("compile" in the respective subprojects)
+ * - Running JUnit tests ("test") and partest ("test/it:test")
+ * - Creating build-sbt/quick with all compiled classes and launcher scripts ("dist/mkQuick")
+ * - Creating build-sbt/pack with all JARs and launcher scripts ("dist/mkPack")
+ * - Building all scaladoc sets ("doc")
+ * - Publishing ("publishDists" and standard sbt tasks like "publish" and "publishLocal")
*
* You'll notice that this build definition is much more complicated than your typical sbt build.
* The main reason is that we are not benefiting from sbt's conventions when it comes project
@@ -50,15 +53,21 @@
* https://groups.google.com/d/topic/scala-internals/gp5JsM1E0Fo/discussion
*/
+import VersionUtil._
+
val bootstrapScalaVersion = versionProps("starr.version")
def withoutScalaLang(moduleId: ModuleID): ModuleID = moduleId exclude("org.scala-lang", "*")
// exclusion of the scala-library transitive dependency avoids eviction warnings during `update`.
+val actorsMigrationDep = withoutScalaLang("org.scala-lang" %% "scala-actors-migration" % versionNumber("actors-migration"))
+val akkaActorDep = withoutScalaLang("com.typesafe.akka" %% "akka-actor" % versionNumber("akka-actor"))
+val scalaContinuationsLibraryDep = withoutScalaLang("org.scala-lang.plugins" %% "scala-continuations-library" % versionNumber("scala-continuations-library"))
+val scalaContinuationsPluginDep = withoutScalaLang("org.scala-lang.plugins" % ("scala-continuations-plugin_" + versionProps("scala.full.version")) % versionNumber("scala-continuations-plugin"))
val scalaParserCombinatorsDep = withoutScalaLang("org.scala-lang.modules" %% "scala-parser-combinators" % versionNumber("scala-parser-combinators"))
+val scalaSwingDep = withoutScalaLang("org.scala-lang.modules" %% "scala-swing" % versionNumber("scala-swing"))
val scalaXmlDep = withoutScalaLang("org.scala-lang.modules" %% "scala-xml" % versionNumber("scala-xml"))
val partestDep = withoutScalaLang("org.scala-lang.modules" %% "scala-partest" % versionNumber("partest"))
-val partestInterfaceDep = withoutScalaLang("org.scala-lang.modules" %% "scala-partest-interface" % "0.5.0")
val junitDep = "junit" % "junit" % "4.11"
val junitIntefaceDep = "com.novocode" % "junit-interface" % "0.11" % "test"
val asmDep = "org.scala-lang.modules" % "scala-asm" % versionProps("scala-asm.version")
@@ -66,9 +75,49 @@ val jlineDep = "jline" % "jline" % versionProps("jline.version")
val antDep = "org.apache.ant" % "ant" % "1.9.4"
val scalacheckDep = withoutScalaLang("org.scalacheck" %% "scalacheck" % versionNumber("scalacheck") % "it")
-lazy val commonSettings = clearSourceAndResourceDirectories ++ Seq[Setting[_]](
+/** Publish to ./dists/maven-sbt, similar to the ANT build which publishes to ./dists/maven. This
+ * can be used to compare the output of the sbt and ANT builds during the transition period. Any
+ * real publishing should be done with sbt's standard `publish` task. */
+lazy val publishDists = taskKey[Unit]("Publish to ./dists/maven-sbt.")
+
+lazy val publishSettings : Seq[Setting[_]] = Seq(
+ publishDists := {
+ val artifacts = (packagedArtifacts in publish).value
+ val ver = VersionUtil.versionProperties.value.canonicalVersion
+ val log = streams.value.log
+ val mappings = artifacts.toSeq.map { case (a, f) =>
+ val typeSuffix = a.`type` match {
+ case "pom" => "-pom.xml"
+ case "bundle" | "jar" => ".jar"
+ case "doc" => "-docs.jar"
+ case tpe => s"-$tpe.${a.extension}"
+ }
+ val to = file("dists/maven-sbt") / ver / a.name / (a.name + typeSuffix)
+ log.info(s"Publishing $f to $to")
+ (f, to)
+ }
+ IO.copy(mappings)
+ },
+ credentials ++= {
+ val file = Path.userHome / ".credentials"
+ if (file.exists) List(Credentials(file))
+ else Nil
+ },
+ publishMavenStyle := true
+)
+
+// Set the version number: The ANT build uses the file "build.number" to get the base version. Overriding versions or
+// suffixes for certain builds is done by directly setting variables from the shell scripts. For example, in
+// publish-core this requires computing the commit SHA first and then passing it to ANT. In the sbt build we use
+// the two settings `baseVersion` and `baseVersionSuffix` to compute all versions (canonical, Maven, OSGi). See
+// VersionUtil.versionPropertiesImpl for details. The standard sbt `version` setting should not be set directly. It
+// is the same as the Maven version and derived automatically from `baseVersion` and `baseVersionSuffix`.
+globalVersionSettings
+baseVersion in Global := "2.11.8"
+baseVersionSuffix in Global := "SNAPSHOT"
+
+lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings ++ Seq[Setting[_]](
organization := "org.scala-lang",
- version := "2.11.8-SNAPSHOT",
scalaVersion := bootstrapScalaVersion,
// we don't cross build Scala itself
crossPaths := false,
@@ -90,6 +139,7 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ Seq[Setting[_]](
unmanagedJars in Compile := Seq.empty,
sourceDirectory in Compile := baseDirectory.value,
unmanagedSourceDirectories in Compile := List(baseDirectory.value),
+ unmanagedResourceDirectories in Compile += (baseDirectory in ThisBuild).value / "src" / thisProject.value.id,
scalaSource in Compile := (sourceDirectory in Compile).value,
javaSource in Compile := (sourceDirectory in Compile).value,
// resources are stored along source files in our current layout
@@ -97,26 +147,124 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ Seq[Setting[_]](
// each subproject has to ask specifically for files they want to include
includeFilter in unmanagedResources in Compile := NothingFilter,
target := (baseDirectory in ThisBuild).value / "target" / thisProject.value.id,
- target in Compile in doc := buildDirectory.value / "scaladoc" / thisProject.value.id,
classDirectory in Compile := buildDirectory.value / "quick/classes" / thisProject.value.id,
- // given that classDirectory is overriden to be _outside_ of target directory, we have
- // to make sure its being cleaned properly
+ target in Compile in doc := buildDirectory.value / "scaladoc" / thisProject.value.id,
+ // given that classDirectory and doc target are overriden to be _outside_ of target directory, we have
+ // to make sure they are being cleaned properly
cleanFiles += (classDirectory in Compile).value,
- fork in run := true
+ cleanFiles += (target in Compile in doc).value,
+ fork in run := true,
+ scalacOptions in Compile in doc ++= Seq(
+ "-doc-footer", "epfl",
+ "-diagrams",
+ "-implicits",
+ "-groups",
+ "-doc-version", versionProperties.value.canonicalVersion,
+ "-doc-title", description.value,
+ "-sourcepath", (baseDirectory in ThisBuild).value.toString,
+ "-doc-source-url", s"https://github.com/scala/scala/tree/${versionProperties.value.githubTree}€{FILE_PATH}.scala#L1"
+ ),
+ homepage := Some(url("http://www.scala-lang.org")),
+ startYear := Some(2002),
+ licenses += ("BSD 3-Clause", url("http://www.scala-lang.org/license.html")),
+ apiURL := Some(url("http://www.scala-lang.org/api/" + versionProperties.value.mavenVersion + "/")),
+ pomIncludeRepository := { _ => false },
+ pomExtra := {
+ val base =
+ <scm>
+ <connection>scm:git:git://github.com/scala/scala.git</connection>
+ <url>https://github.com/scala/scala.git</url>
+ </scm>
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://issues.scala-lang.org/</url>
+ </issueManagement>
+ <developers>
+ <developer>
+ <id>lamp</id>
+ <name>EPFL LAMP</name>
+ </developer>
+ <developer>
+ <id>Lightbend</id>
+ <name>Lightbend, Inc.</name>
+ </developer>
+ </developers>
+ apiURL.value match {
+ case Some(url) => base ++
+ <properties>
+ <info.apiURL>{url.toString}</info.apiURL>
+ </properties>
+ case None => base
+ }
+ },
+ // Remove auto-generated manifest attributes
+ packageOptions in Compile in packageBin := Seq.empty,
+ packageOptions in Compile in packageSrc := Seq.empty,
+
+ // Lets us CTRL-C partest without exiting SBT entirely
+ cancelable in Global := true,
+ // When we fork subprocesses, use the base directory as the working directory.
+ // This enables `sbt> partest test/files/run/t1.scala` or `sbt> scalac sandbox/test.scala`
+ baseDirectory in Compile := (baseDirectory in ThisBuild).value,
+ baseDirectory in Test := (baseDirectory in ThisBuild).value,
+
+ // Don't log process output (e.g. of forked `compiler/runMain ...Main`), just pass it
+ // directly to stdout
+ outputStrategy in run := Some(StdoutOutput)
)
-// disable various tasks that are not needed for projects that are used
-// only for compiling code and not publishing it as a standalone artifact
-// we disable those tasks by overriding them and returning bogus files when
-// needed. This is a bit sketchy but I haven't found any better way.
-val disableDocsAndPublishingTasks = Seq[Setting[_]](
- doc := file("!!! NO DOCS !!!"),
- publishLocal := {},
- publish := {},
- packageBin in Compile := file("!!! NO PACKAGING !!!")
+/** Extra post-processing for the published POM files. These are needed to create POMs that
+ * are equivalent to the ones from the ANT build. In the long term this should be removed and
+ * POMs, scaladocs, OSGi manifests, etc. should all use the same metadata. */
+def fixPom(extra: (String, scala.xml.Node)*): Setting[_] = {
+ /** Find elements in an XML document by a simple XPath and replace them */
+ def fixXML(n: scala.xml.Node, repl: Map[String, scala.xml.Node]): scala.xml.Node = {
+ def f(n: scala.xml.Node, p: String): scala.xml.Node = n match {
+ case e: scala.xml.Elem =>
+ val pp = p + "/" + e.label
+ repl.get(pp) match {
+ case Some(xml) => xml
+ case None => e.copy(child = e.child.map(ch => f(ch, pp)))
+ }
+ case n => n
+ }
+ f(n, "")
+ }
+ pomPostProcess := { n => fixXML(pomPostProcess.value.apply(n), Map(
+ "/project/organization" ->
+ <organization>
+ <name>LAMP/EPFL</name>
+ <url>http://lamp.epfl.ch/</url>
+ </organization>,
+ "/project/url" -> <url>http://www.scala-lang.org/</url>
+ ) ++ extra) }
+}
+
+/** Remove unwanted dependencies from the POM. */
+def removePomDependencies(deps: (String, String)*): Setting[_] = {
+ pomPostProcess := { n =>
+ val n2 = pomPostProcess.value.apply(n)
+ import scala.xml._
+ import scala.xml.transform._
+ (new RuleTransformer(new RewriteRule {
+ override def transform(node: Node) = node match {
+ case e: Elem if e.label == "dependency" &&
+ deps.exists { case (g, a) =>
+ e.child.contains(<groupId>{g}</groupId>) &&
+ (e.child.contains(<artifactId>{a}</artifactId>) || e.child.contains(<artifactId>{a + "_" + scalaBinaryVersion.value}</artifactId>))
+ } => Seq.empty
+ case n => Seq(n)
+ }
+ })).transform(Seq(n2)).head
+ }
+}
+
+val disableDocs = Seq[Setting[_]](
+ sources in (Compile, doc) := Seq.empty,
+ publishArtifact in (Compile, packageDoc) := false
)
-lazy val setJarLocation: Setting[_] =
+lazy val setJarLocation: Setting[_] =
artifactPath in packageBin in Compile := {
// two lines below are copied over from sbt's sources:
// https://github.com/sbt/sbt/blob/0.13/main/src/main/scala/sbt/Defaults.scala#L628
@@ -130,101 +278,259 @@ lazy val setJarLocation: Setting[_] =
}
lazy val scalaSubprojectSettings: Seq[Setting[_]] = commonSettings :+ setJarLocation
-lazy val generatePropertiesFileSettings = Seq[Setting[_]](
- copyrightString := "Copyright 2002-2015, LAMP/EPFL",
- resourceGenerators in Compile += generateVersionPropertiesFile.map(file => Seq(file)).taskValue,
- generateVersionPropertiesFile := generateVersionPropertiesFileImpl.value
+def filterDocSources(ff: FileFilter): Seq[Setting[_]] = Seq(
+ sources in (Compile, doc) ~= (_.filter(ff.accept _)),
+ // Excluded sources may still be referenced by the included sources, so we add the compiler
+ // output to the scaladoc classpath to resolve them. For the `library` project this is
+ // always required because otherwise the compiler cannot even initialize Definitions without
+ // binaries of the library on the classpath. Specifically, we get this error:
+ // (library/compile:doc) scala.reflect.internal.FatalError: package class scala does not have a member Int
+ // Ant build does the same thing always: it puts binaries for documented classes on the classpath
+ // sbt never does this by default (which seems like a good default)
+ dependencyClasspath in (Compile, doc) += (classDirectory in Compile).value,
+ doc in Compile <<= doc in Compile dependsOn (compile in Compile)
)
-val libIncludes: FileFilter = "*.tmpl" | "*.xml" | "*.js" | "*.css" | "rootdoc.txt"
+def regexFileFilter(s: String): FileFilter = new FileFilter {
+ val pat = s.r.pattern
+ def accept(f: File) = pat.matcher(f.getAbsolutePath.replace('\\', '/')).matches()
+}
lazy val library = configureAsSubproject(project)
.settings(generatePropertiesFileSettings: _*)
+ .settings(Osgi.settings: _*)
.settings(
name := "scala-library",
+ description := "Scala Standard Library",
scalacOptions in Compile ++= Seq[String]("-sourcepath", (scalaSource in Compile).value.toString),
- // Workaround for a bug in `scaladoc` that it seems to not respect the `-sourcepath` option
- // as a result of this bug, the compiler cannot even initialize Definitions without
- // binaries of the library on the classpath. Specifically, we get this error:
- // (library/compile:doc) scala.reflect.internal.FatalError: package class scala does not have a member Int
- // Ant build does the same thing always: it puts binaries for documented classes on the classpath
- // sbt never does this by default (which seems like a good default)
- dependencyClasspath in Compile in doc += (classDirectory in Compile).value,
scalacOptions in Compile in doc ++= {
val libraryAuxDir = (baseDirectory in ThisBuild).value / "src/library-aux"
- Seq("-doc-no-compile", libraryAuxDir.toString)
+ Seq(
+ "-doc-no-compile", libraryAuxDir.toString,
+ "-skip-packages", "scala.concurrent.impl",
+ "-doc-root-content", (sourceDirectory in Compile).value + "/rootdoc.txt"
+ )
+ },
+ includeFilter in unmanagedResources in Compile := "*.tmpl" | "*.xml" | "*.js" | "*.css" | "rootdoc.txt",
+ // Include *.txt files in source JAR:
+ mappings in Compile in packageSrc ++= {
+ val base = (unmanagedResourceDirectories in Compile).value
+ base ** "*.txt" pair relativeTo(base)
},
- includeFilter in unmanagedResources in Compile := libIncludes)
- .dependsOn (forkjoin)
+ // Include forkjoin classes in scala-library.jar
+ products in Compile in packageBin ++=
+ (products in Compile in packageBin in forkjoin).value,
+ Osgi.headers += "Import-Package" -> "sun.misc;resolution:=optional, *",
+ fixPom(
+ "/project/name" -> <name>Scala Library</name>,
+ "/project/description" -> <description>Standard library for the Scala Programming Language</description>,
+ "/project/packaging" -> <packaging>jar</packaging>
+ ),
+ // Remove the dependency on "forkjoin" from the POM because it is included in the JAR:
+ removePomDependencies(("org.scala-lang", "forkjoin"))
+ )
+ .settings(filterDocSources("*.scala" -- (regexFileFilter(".*/runtime/.*\\$\\.scala") ||
+ regexFileFilter(".*/runtime/ScalaRunTime\\.scala") ||
+ regexFileFilter(".*/runtime/StringAdd\\.scala"))): _*)
+ .dependsOn(forkjoin)
lazy val reflect = configureAsSubproject(project)
.settings(generatePropertiesFileSettings: _*)
- .settings(name := "scala-reflect")
+ .settings(Osgi.settings: _*)
+ .settings(
+ name := "scala-reflect",
+ description := "Scala Reflection Library",
+ Osgi.bundleName := "Scala Reflect",
+ scalacOptions in Compile in doc ++= Seq(
+ "-skip-packages", "scala.reflect.macros.internal:scala.reflect.internal:scala.reflect.io"
+ ),
+ Osgi.headers +=
+ "Import-Package" -> ("scala.*;version=\"${range;[==,=+);${ver}}\","+
+ "scala.tools.nsc;resolution:=optional;version=\"${range;[==,=+);${ver}}\","+
+ "*"),
+ fixPom(
+ "/project/name" -> <name>Scala Compiler</name>,
+ "/project/description" -> <description>Compiler for the Scala Programming Language</description>,
+ "/project/packaging" -> <packaging>jar</packaging>
+ )
+ )
.dependsOn(library)
-val compilerIncludes: FileFilter =
- "*.tmpl" | "*.xml" | "*.js" | "*.css" | "*.html" | "*.properties" | "*.swf" |
- "*.png" | "*.gif" | "*.gif" | "*.txt"
-
lazy val compiler = configureAsSubproject(project)
.settings(generatePropertiesFileSettings: _*)
+ .settings(Osgi.settings: _*)
.settings(
name := "scala-compiler",
+ description := "Scala Compiler",
libraryDependencies ++= Seq(antDep, asmDep),
+ // These are only needed for the POM:
+ libraryDependencies ++= Seq(scalaXmlDep, scalaParserCombinatorsDep, jlineDep % "optional"),
// this a way to make sure that classes from interactive and scaladoc projects
// end up in compiler jar (that's what Ant build does)
// we need to use LocalProject references (with strings) to deal with mutual recursion
- mappings in Compile in packageBin :=
- (mappings in Compile in packageBin).value ++
- dependencyClasses(
- (externalDependencyClasspath in Compile).value,
- modules = Set(asmDep),
- keep = "*.class" || "scala-asm.properties",
- streams.value.cacheDirectory) ++
- (mappings in Compile in packageBin in LocalProject("interactive")).value ++
- (mappings in Compile in packageBin in LocalProject("scaladoc")).value ++
- (mappings in Compile in packageBin in LocalProject("repl")).value,
- includeFilter in unmanagedResources in Compile := compilerIncludes)
+ products in Compile in packageBin :=
+ (products in Compile in packageBin).value ++
+ Seq((dependencyClasspath in Compile).value.find(_.get(moduleID.key) == Some(asmDep)).get.data) ++
+ (products in Compile in packageBin in LocalProject("interactive")).value ++
+ (products in Compile in packageBin in LocalProject("scaladoc")).value ++
+ (products in Compile in packageBin in LocalProject("repl")).value ++
+ (products in Compile in packageBin in LocalProject("repl-jline")).value ++
+ (products in Compile in packageBin in LocalProject("repl-jline-embedded")).value,
+ includeFilter in unmanagedResources in Compile :=
+ "*.tmpl" | "*.xml" | "*.js" | "*.css" | "*.html" | "*.properties" | "*.swf" |
+ "*.png" | "*.gif" | "*.gif" | "*.txt",
+ // Also include the selected unmanaged resources and source files from the additional projects in the source JAR:
+ mappings in Compile in packageSrc ++= {
+ val base = (unmanagedResourceDirectories in Compile).value ++
+ (unmanagedResourceDirectories in Compile in LocalProject("interactive")).value ++
+ (unmanagedResourceDirectories in Compile in LocalProject("scaladoc")).value ++
+ (unmanagedResourceDirectories in Compile in LocalProject("repl")).value
+ base ** ((includeFilter in unmanagedResources in Compile).value || "*.scala" || "*.psd" || "*.ai" || "*.java") pair relativeTo(base)
+ },
+ scalacOptions in Compile in doc ++= Seq(
+ "-doc-root-content", (sourceDirectory in Compile).value + "/rootdoc.txt"
+ ),
+ Osgi.headers +=
+ "Import-Package" -> ("jline.*;resolution:=optional," +
+ "org.apache.tools.ant.*;resolution:=optional," +
+ "scala.util.parsing.*;version=\"${range;[====,====];"+versionNumber("scala-parser-combinators")+"}\";resolution:=optional," +
+ "scala.xml.*;version=\"${range;[====,====];"+versionNumber("scala-xml")+"}\";resolution:=optional," +
+ "scala.*;version=\"${range;[==,=+);${ver}}\"," +
+ "*"),
+ // Generate the ScriptEngineFactory service definition. The ant build does this when building
+ // the JAR but sbt has no support for it and it is easier to do as a resource generator:
+ generateServiceProviderResources("javax.script.ScriptEngineFactory" -> "scala.tools.nsc.interpreter.IMain$Factory"),
+ managedResourceDirectories in Compile := Seq((resourceManaged in Compile).value),
+ fixPom(
+ "/project/name" -> <name>Scala Compiler</name>,
+ "/project/description" -> <description>Compiler for the Scala Programming Language</description>,
+ "/project/packaging" -> <packaging>jar</packaging>
+ ),
+ apiURL := None,
+ removePomDependencies(
+ ("org.apache.ant", "ant"),
+ ("org.scala-lang.modules", "scala-asm")
+ )
+ )
.dependsOn(library, reflect)
lazy val interactive = configureAsSubproject(project)
- .settings(disableDocsAndPublishingTasks: _*)
+ .settings(disableDocs: _*)
+ .settings(
+ name := "scala-compiler-interactive",
+ description := "Scala Interactive Compiler",
+ publishArtifact := false
+ )
.dependsOn(compiler)
-// TODO: SI-9339 embed shaded copy of jline & its interface (see #4563)
lazy val repl = configureAsSubproject(project)
+ .settings(disableDocs: _*)
.settings(
- libraryDependencies += jlineDep,
connectInput in run := true,
- outputStrategy in run := Some(StdoutOutput),
+ publishArtifact := false,
run <<= (run in Compile).partialInput(" -usejavacp") // Automatically add this so that `repl/run` works without additional arguments.
)
- .settings(disableDocsAndPublishingTasks: _*)
.dependsOn(compiler, interactive)
+lazy val replJline = configureAsSubproject(Project("repl-jline", file(".") / "src" / "repl-jline"))
+ .settings(disableDocs: _*)
+ .settings(
+ libraryDependencies += jlineDep,
+ name := "scala-repl-jline",
+ publishArtifact := false
+ )
+ .dependsOn(repl)
+
+lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target" / "repl-jline-embedded-src-dummy")
+ .settings(scalaSubprojectSettings: _*)
+ .settings(
+ name := "scala-repl-jline-embedded",
+ // There is nothing to compile for this project. Instead we use the compile task to create
+ // shaded versions of repl-jline and jline.jar. dist/mkBin puts all of quick/repl,
+ // quick/repl-jline and quick/repl-jline-shaded on the classpath for quick/bin scripts.
+ // This is different from the ant build where all parts are combined into quick/repl, but
+ // it is cleaner because it avoids circular dependencies.
+ compile in Compile <<= (compile in Compile).dependsOn(Def.task {
+ import java.util.jar._
+ import collection.JavaConverters._
+ val inputs: Iterator[JarJar.Entry] = {
+ val repljlineClasses = (products in Compile in replJline).value.flatMap(base => Path.allSubpaths(base).map(x => (base, x._1)))
+ val jlineJAR = (dependencyClasspath in Compile).value.find(_.get(moduleID.key) == Some(jlineDep)).get.data
+ val jarFile = new JarFile(jlineJAR)
+ val jarEntries = jarFile.entries.asScala.filterNot(_.isDirectory).map(entry => JarJar.JarEntryInput(jarFile, entry))
+ def compiledClasses = repljlineClasses.iterator.map { case (base, file) => JarJar.FileInput(base, file) }
+ (jarEntries ++ compiledClasses).filter(x =>
+ x.name.endsWith(".class") || x.name.endsWith(".properties") || x.name.startsWith("META-INF/native") || x.name.startsWith("META-INF/maven")
+ )
+ }
+ //println(inputs.map(_.name).mkString("\n"))
+ import JarJar.JarJarConfig._
+ val config: Seq[JarJar.JarJarConfig] = Seq(
+ Rule("org.fusesource.**", "scala.tools.fusesource_embedded.@1"),
+ Rule("jline.**", "scala.tools.jline_embedded.@1"),
+ Rule("scala.tools.nsc.interpreter.jline.**", "scala.tools.nsc.interpreter.jline_embedded.@1"),
+ Keep("scala.tools.**")
+ )
+ val outdir = (classDirectory in Compile).value
+ JarJar(inputs, outdir, config)
+ }),
+ publishArtifact := false,
+ connectInput in run := true
+ )
+ .dependsOn(replJline)
+
lazy val scaladoc = configureAsSubproject(project)
+ .settings(disableDocs: _*)
.settings(
- libraryDependencies ++= Seq(scalaXmlDep, scalaParserCombinatorsDep, partestDep)
+ name := "scala-compiler-doc",
+ description := "Scala Documentation Generator",
+ libraryDependencies ++= Seq(scalaXmlDep, scalaParserCombinatorsDep, partestDep),
+ publishArtifact := false,
+ includeFilter in unmanagedResources in Compile := "*.html" | "*.css" | "*.gif" | "*.png" | "*.js" | "*.txt"
)
- .settings(disableDocsAndPublishingTasks: _*)
.dependsOn(compiler)
-lazy val scalap = configureAsSubproject(project).
- dependsOn(compiler)
+lazy val scalap = configureAsSubproject(project)
+ .settings(
+ description := "Scala Bytecode Parser",
+ // Include decoder.properties
+ includeFilter in unmanagedResources in Compile := "*.properties",
+ fixPom(
+ "/project/name" -> <name>Scalap</name>,
+ "/project/description" -> <description>bytecode analysis tool</description>,
+ "/project/properties" -> scala.xml.Text("")
+ )
+ )
+ .dependsOn(compiler)
// deprecated Scala Actors project
-// TODO: it packages into actors.jar but it should be scala-actors.jar
lazy val actors = configureAsSubproject(project)
.settings(generatePropertiesFileSettings: _*)
- .settings(name := "scala-actors")
+ .settings(Osgi.settings: _*)
+ .settings(
+ name := "scala-actors",
+ description := "Scala Actors Library",
+ Osgi.bundleName := "Scala Actors",
+ startYear := Some(2006),
+ fixPom(
+ "/project/name" -> <name>Scala Actors library</name>,
+ "/project/description" -> <description>Deprecated Actors Library for Scala</description>,
+ "/project/packaging" -> <packaging>jar</packaging>
+ )
+ )
+ .settings(filterDocSources("*.scala"): _*)
.dependsOn(library)
lazy val forkjoin = configureAsForkOfJavaProject(project)
lazy val partestExtras = configureAsSubproject(Project("partest-extras", file(".") / "src" / "partest-extras"))
- .dependsOn(repl)
+ .dependsOn(replJlineEmbedded)
.settings(clearSourceAndResourceDirectories: _*)
+ .settings(disableDocs: _*)
.settings(
+ name := "scala-partest-extras",
+ description := "Scala Compiler Testing Tool (compiler-specific extras)",
+ publishArtifact := false,
libraryDependencies += partestDep,
unmanagedSourceDirectories in Compile := List(baseDirectory.value)
)
@@ -233,22 +539,26 @@ lazy val junit = project.in(file("test") / "junit")
.dependsOn(library, reflect, compiler, partestExtras, scaladoc)
.settings(clearSourceAndResourceDirectories: _*)
.settings(commonSettings: _*)
+ .settings(disableDocs: _*)
.settings(
+ publishArtifact := false,
fork in Test := true,
libraryDependencies ++= Seq(junitDep, junitIntefaceDep),
testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-v"),
unmanagedSourceDirectories in Test := List(baseDirectory.value)
)
-lazy val partestJavaAgent = (project in file(".") / "src" / "partest-javaagent").
- settings(commonSettings: _*).
- settings(
+lazy val partestJavaAgent = Project("partest-javaagent", file(".") / "src" / "partest-javaagent")
+ .settings(commonSettings: _*)
+ .settings(generatePropertiesFileSettings: _*)
+ .settings(disableDocs: _*)
+ .settings(
libraryDependencies += asmDep,
- doc := file("!!! NO DOCS !!!"),
publishLocal := {},
publish := {},
// Setting name to "scala-partest-javaagent" so that the jar file gets that name, which the Runner relies on
name := "scala-partest-javaagent",
+ description := "Scala Compiler Testing Tool (compiler-specific java agent)",
// writing jar file to $buildDirectory/pack/lib because that's where it's expected to be found
setJarLocation,
// add required manifest entry - previously included from file
@@ -258,24 +568,26 @@ lazy val partestJavaAgent = (project in file(".") / "src" / "partest-javaagent")
exportJars := true
)
-lazy val test = project.
- dependsOn(compiler, interactive, actors, repl, scalap, partestExtras, partestJavaAgent, scaladoc).
- configs(IntegrationTest).
- settings(disableDocsAndPublishingTasks: _*).
- settings(commonSettings: _*).
- settings(Defaults.itSettings: _*).
- settings(
- libraryDependencies ++= Seq(asmDep, partestDep, scalaXmlDep, partestInterfaceDep, scalacheckDep),
- unmanagedBase in Test := baseDirectory.value / "files" / "lib",
- unmanagedJars in Test <+= (unmanagedBase) (j => Attributed.blank(j)) map(identity),
+lazy val test = project
+ .dependsOn(compiler, interactive, actors, replJlineEmbedded, scalap, partestExtras, partestJavaAgent, scaladoc)
+ .configs(IntegrationTest)
+ .settings(commonSettings: _*)
+ .settings(disableDocs: _*)
+ .settings(Defaults.itSettings: _*)
+ .settings(
+ publishArtifact := false,
+ libraryDependencies ++= Seq(asmDep, partestDep, scalaXmlDep, scalacheckDep),
+ unmanagedBase in IntegrationTest := baseDirectory.value / "files" / "lib",
+ unmanagedJars in IntegrationTest <+= (unmanagedBase) (j => Attributed.blank(j)) map(identity),
// no main sources
sources in Compile := Seq.empty,
// test sources are compiled in partest run, not here
sources in IntegrationTest := Seq.empty,
fork in IntegrationTest := true,
javaOptions in IntegrationTest += "-Xmx1G",
- testFrameworks += new TestFramework("scala.tools.partest.Framework"),
+ testFrameworks += new TestFramework("scala.tools.partest.sbt.Framework"),
testOptions in IntegrationTest += Tests.Setup( () => root.base.getAbsolutePath + "/pull-binary-libs.sh" ! ),
+ testOptions in IntegrationTest += Tests.Argument("-Dpartest.java_opts=-Xmx1024M -Xms64M -XX:MaxPermSize=128M"),
definedTests in IntegrationTest += (
new sbt.TestDefinition(
"partest",
@@ -288,9 +600,88 @@ lazy val test = project.
)
)
-lazy val root = (project in file(".")).
- aggregate(library, forkjoin, reflect, compiler, interactive, repl,
- scaladoc, scalap, actors, partestExtras, junit).settings(
+lazy val manual = configureAsSubproject(project)
+ .settings(disableDocs: _*)
+ .settings(
+ publishArtifact := false,
+ libraryDependencies ++= Seq(scalaXmlDep, antDep),
+ classDirectory in Compile := (target in Compile).value / "classes"
+ )
+ .dependsOn(library)
+
+lazy val libraryAll = Project("library-all", file(".") / "target" / "library-all-src-dummy")
+ .settings(commonSettings: _*)
+ .settings(disableDocs: _*)
+ .settings(
+ name := "scala-library-all",
+ publishArtifact in (Compile, packageBin) := false,
+ publishArtifact in (Compile, packageSrc) := false,
+ libraryDependencies ++= Seq(scalaXmlDep, scalaParserCombinatorsDep, scalaContinuationsLibraryDep, scalaSwingDep, akkaActorDep, actorsMigrationDep),
+ apiURL := None,
+ fixPom(
+ "/project/name" -> <name>Scala Library Powerpack</name>,
+ "/project/description" -> <description>The Scala Standard Library and Official Modules</description>
+ )
+ )
+ .dependsOn(library, reflect)
+
+lazy val scalaDist = Project("scala-dist", file(".") / "target" / "scala-dist-dist-src-dummy")
+ .settings(commonSettings: _*)
+ .settings(disableDocs: _*)
+ .settings(
+ mappings in Compile in packageBin ++= {
+ val binBaseDir = buildDirectory.value / "pack"
+ val binMappings = (mkBin in dist).value.pair(relativeTo(binBaseDir), errorIfNone = false)
+ // With the way the resource files are spread out over the project sources we can't just add
+ // an unmanagedResourceDirectory, so we generate the mappings manually:
+ val docBaseDir = (baseDirectory in ThisBuild).value
+ val docMappings = (docBaseDir / "doc").*** pair relativeTo(docBaseDir)
+ val resBaseDir = (baseDirectory in ThisBuild).value / "src/manual/scala/tools/docutil/resources"
+ val resMappings = resBaseDir ** ("*.html" | "*.css" | "*.gif" | "*.png") pair (p => relativeTo(resBaseDir)(p).map("doc/tools/" + _))
+ docMappings ++ resMappings ++ binMappings
+ },
+ resourceGenerators in Compile += Def.task {
+ val command = "fsc, scala, scalac, scaladoc, scalap"
+ val htmlOut = (resourceManaged in Compile).value / "doc/tools"
+ val manOut = (resourceManaged in Compile).value / "genman"
+ val fixedManOut = (resourceManaged in Compile).value / "man"
+ IO.createDirectory(htmlOut)
+ IO.createDirectory(manOut / "man1")
+ toError(runner.value.run("scala.tools.docutil.ManMaker",
+ (fullClasspath in Compile in manual).value.files,
+ Seq(command, htmlOut.getAbsolutePath, manOut.getAbsolutePath),
+ streams.value.log))
+ (manOut ** "*.1" pair rebase(manOut, fixedManOut)).foreach { case (in, out) =>
+ // Generated manpages should always use LF only. There doesn't seem to be a good reason
+ // for generating them with the platform EOL first and then converting them but that's
+ // what the ant build does.
+ IO.write(out, IO.readBytes(in).filterNot(_ == '\r'))
+ }
+ (htmlOut ** "*.html").get ++ (fixedManOut ** "*.1").get
+ }.taskValue,
+ managedResourceDirectories in Compile := Seq((resourceManaged in Compile).value),
+ libraryDependencies ++= Seq(scalaContinuationsPluginDep, jlineDep),
+ apiURL := None,
+ fixPom(
+ "/project/name" -> <name>Scala Distribution Artifacts</name>,
+ "/project/description" -> <description>The Artifacts Distributed with Scala</description>,
+ "/project/packaging" -> <packaging>jar</packaging>
+ ),
+ publishArtifact in (Compile, packageSrc) := false
+ )
+ .dependsOn(libraryAll, compiler, scalap)
+
+lazy val root = (project in file("."))
+ .settings(disableDocs: _*)
+ .settings(generateBuildCharacterFileSettings: _*)
+ .settings(
+ publishArtifact := false,
+ publish := {},
+ publishLocal := {},
+ commands ++= ScriptCommands.all
+ )
+ .aggregate(library, forkjoin, reflect, compiler, interactive, repl, replJline, replJlineEmbedded,
+ scaladoc, scalap, actors, partestExtras, junit, libraryAll, scalaDist).settings(
sources in Compile := Seq.empty,
onLoadMessage := """|*** Welcome to the sbt build definition for Scala! ***
|This build definition has an EXPERIMENTAL status. If you are not
@@ -298,9 +689,41 @@ lazy val root = (project in file(".")).
|the Ant build definition for now. Check README.md for more information.""".stripMargin
)
-lazy val dist = (project in file("dist")).settings(
- mkBin := mkBinImpl.value
-)
+// The following subprojects' binaries are required for building "pack":
+lazy val distDependencies = Seq(replJline, replJlineEmbedded, compiler, library, partestExtras, partestJavaAgent, reflect, scalap, actors, scaladoc)
+
+lazy val dist = (project in file("dist"))
+ .settings(commonSettings)
+ .settings(
+ libraryDependencies ++= Seq(scalaContinuationsLibraryDep, scalaContinuationsPluginDep, scalaSwingDep, jlineDep),
+ mkBin := mkBinImpl.value,
+ mkQuick <<= Def.task {
+ val cp = (fullClasspath in IntegrationTest in LocalProject("test")).value
+ val propsFile = (buildDirectory in ThisBuild).value / "quick" / "partest.properties"
+ val props = new java.util.Properties()
+ props.setProperty("partest.classpath", cp.map(_.data.getAbsolutePath).mkString(sys.props("path.separator")))
+ IO.write(props, null, propsFile)
+ } dependsOn ((distDependencies.map(products in Runtime in _) :+ mkBin): _*),
+ mkPack <<= Def.task {} dependsOn (packagedArtifact in (Compile, packageBin), mkBin),
+ target := (baseDirectory in ThisBuild).value / "target" / thisProject.value.id,
+ packageBin in Compile := {
+ val extraDeps = Set(scalaContinuationsLibraryDep, scalaContinuationsPluginDep, scalaSwingDep, scalaParserCombinatorsDep, scalaXmlDep)
+ val targetDir = (buildDirectory in ThisBuild).value / "pack" / "lib"
+ def uniqueModule(m: ModuleID) = (m.organization, m.name.replaceFirst("_.*", ""))
+ val extraModules = extraDeps.map(uniqueModule)
+ val extraJars = (externalDependencyClasspath in Compile).value.map(a => (a.get(moduleID.key), a.data)).collect {
+ case (Some(m), f) if extraModules contains uniqueModule(m) => f
+ }
+ val jlineJAR = (dependencyClasspath in Compile).value.find(_.get(moduleID.key) == Some(jlineDep)).get.data
+ val mappings = extraJars.map(f => (f, targetDir / f.getName)) :+ (jlineJAR, targetDir / "jline.jar")
+ IO.copy(mappings, overwrite = true)
+ targetDir
+ },
+ cleanFiles += (buildDirectory in ThisBuild).value / "quick",
+ cleanFiles += (buildDirectory in ThisBuild).value / "pack",
+ packagedArtifact in (Compile, packageBin) <<= (packagedArtifact in (Compile, packageBin)).dependsOn(distDependencies.map(packagedArtifact in (Compile, packageBin) in _): _*)
+ )
+ .dependsOn(distDependencies.map(p => p: ClasspathDep[ProjectReference]): _*)
/**
* Configures passed project as a subproject (e.g. compiler or repl)
@@ -315,7 +738,9 @@ lazy val dist = (project in file("dist")).settings(
*/
def configureAsSubproject(project: Project): Project = {
val base = file(".") / "src" / project.id
- (project in base).settings(scalaSubprojectSettings: _*)
+ (project in base)
+ .settings(scalaSubprojectSettings: _*)
+ .settings(generatePropertiesFileSettings: _*)
}
/**
@@ -329,10 +754,11 @@ def configureAsSubproject(project: Project): Project = {
*/
def configureAsForkOfJavaProject(project: Project): Project = {
val base = file(".") / "src" / project.id
- (project in base).
- settings(commonSettings: _*).
- settings(disableDocsAndPublishingTasks: _*).
- settings(
+ (project in base)
+ .settings(commonSettings: _*)
+ .settings(disableDocs: _*)
+ .settings(
+ publishArtifact := false,
sourceDirectory in Compile := baseDirectory.value,
javaSource in Compile := (sourceDirectory in Compile).value,
sources in Compile in doc := Seq.empty,
@@ -341,100 +767,9 @@ def configureAsForkOfJavaProject(project: Project): Project = {
}
lazy val buildDirectory = settingKey[File]("The directory where all build products go. By default ./build")
-lazy val copyrightString = settingKey[String]("Copyright string.")
-lazy val generateVersionPropertiesFile = taskKey[File]("Generating version properties file.")
lazy val mkBin = taskKey[Seq[File]]("Generate shell script (bash or Windows batch).")
-
-lazy val generateVersionPropertiesFileImpl: Def.Initialize[Task[File]] = Def.task {
- val propFile = (resourceManaged in Compile).value / s"${thisProject.value.id}.properties"
- val props = new java.util.Properties
-
- /**
- * Regexp that splits version number split into two parts: version and suffix.
- * Examples of how the split is performed:
- *
- * "2.11.5": ("2.11.5", null)
- * "2.11.5-acda7a": ("2.11.5", "-acda7a")
- * "2.11.5-SNAPSHOT": ("2.11.5", "-SNAPSHOT")
- *
- */
- val versionSplitted = """([\w+\.]+)(-[\w+\.]+)??""".r
-
- val versionSplitted(ver, suffixOrNull) = version.value
- val osgiSuffix = suffixOrNull match {
- case null => "-VFINAL"
- case "-SNAPSHOT" => ""
- case suffixStr => suffixStr
- }
-
- def executeTool(tool: String) = {
- val cmd =
- if (System.getProperty("os.name").toLowerCase.contains("windows"))
- s"cmd.exe /c tools\\$tool.bat -p"
- else s"tools/$tool"
- Process(cmd).lines.head
- }
-
- val commitDate = executeTool("get-scala-commit-date")
- val commitSha = executeTool("get-scala-commit-sha")
-
- props.put("version.number", s"${version.value}-$commitDate-$commitSha")
- props.put("maven.version.number", s"${version.value}")
- props.put("osgi.version.number", s"$ver.v$commitDate$osgiSuffix-$commitSha")
- props.put("copyright.string", copyrightString.value)
-
- // unfortunately, this will write properties in arbitrary order
- // this makes it harder to test for stability of generated artifacts
- // consider using https://github.com/etiennestuder/java-ordered-properties
- // instead of java.util.Properties
- IO.write(props, null, propFile)
-
- propFile
-}
-
-/**
- * Extract selected dependencies to the `cacheDirectory` and return a mapping for the content.
- * Heavily inspired by sbt-assembly (https://github.com/sbt/sbt-assembly/blob/0.13.0/src/main/scala/sbtassembly/Assembly.scala#L157)
- */
-def dependencyClasses(dependencies: Classpath, modules: Set[ModuleID], keep: FileFilter, cacheDirectory: File): Seq[(File, String)] = {
- val dependencyFiles: Seq[File] = dependencies.map(_.data).toSeq
- val toInclude = dependencyFiles.filter(f => {
- val p = f.getCanonicalPath
- modules.exists(m => {
- // works for both .m2 (org/scala-lang/modules/scala-asm/5.0.3-scala-3/scala-asm-5.0.3-scala-3.jar)
- // and .ivy2 (org.scala-lang.modules/scala-asm/5.0.3-scala-3/bundles/scala-asm.jar)
- val nameParts = m.organization.split('.').toSet + m.name + m.revision
- nameParts.forall(p.contains)
- })
- })
- assert(toInclude.forall(sbt.classpath.ClasspathUtilities.isArchive), s"Expected JAR files as dependencies: $toInclude")
-
- val tempDir = cacheDirectory / "unpackedDependencies"
-
- def sha1name(f: File): String = bytesToSha1String(f.getCanonicalPath.getBytes("UTF-8"))
- def sha1content(f: File): String = bytesToSha1String(IO.readBytes(f))
- def bytesToSha1String(bytes: Array[Byte]): String = {
- val sha1 = java.security.MessageDigest.getInstance("SHA-1")
- val hash = sha1.digest(bytes)
- hash map {"%02x".format(_)} mkString
- }
-
- val jarDirs: Seq[File] = for (jar <- toInclude) yield {
- val jarName = jar.getName
- val hash = sha1name(jar) + "_" + sha1content(jar)
- val jarNamePath = tempDir / (hash + ".jarName")
- val dest = tempDir / hash
- if (!jarNamePath.exists || IO.read(jarNamePath) != jar.getCanonicalPath) {
- IO.delete(dest)
- dest.mkdir()
- IO.unzip(jar, dest)
- IO.write(jarNamePath, jar.getCanonicalPath, IO.utf8, append = false)
- }
- dest
- }
-
- jarDirs.flatMap(dir => dir ** keep --- dir pair relativeTo(dir))
-}
+lazy val mkQuick = taskKey[Unit]("Generate a full build, including scripts, in build-sbt/quick")
+lazy val mkPack = taskKey[Unit]("Generate a full build, including scripts, in build-sbt/pack")
// Defining these settings is somewhat redundant as we also redefine settings that depend on them.
// However, IntelliJ's project import works better when these are set correctly.
@@ -446,6 +781,7 @@ def clearSourceAndResourceDirectories = Seq(Compile, Test).flatMap(config => inC
)))
lazy val mkBinImpl: Def.Initialize[Task[Seq[File]]] = Def.task {
+ import java.io.IOException
def mkScalaTool(mainCls: String, classpath: Seq[Attributed[File]]): ScalaTool =
ScalaTool(mainClass = mainCls,
classpath = classpath.toList.map(_.data.getAbsolutePath),
@@ -453,45 +789,65 @@ lazy val mkBinImpl: Def.Initialize[Task[Seq[File]]] = Def.task {
javaOpts = "-Xmx256M -Xms32M",
toolFlags = "")
val rootDir = (classDirectory in Compile in compiler).value
- def writeScripts(scalaTool: ScalaTool, file: String, outDir: File): Seq[File] =
- Seq(
+ val quickOutDir = buildDirectory.value / "quick/bin"
+ val packOutDir = buildDirectory.value / "pack/bin"
+ def writeScripts(scalaTool: ScalaTool, file: String, outDir: File): Seq[File] = {
+ val res = Seq(
scalaTool.writeScript(file, "unix", rootDir, outDir),
scalaTool.writeScript(file, "windows", rootDir, outDir)
)
- def mkQuickBin(file: String, mainCls: String, classpath: Seq[Attributed[File]]): Seq[File] = {
- val scalaTool = mkScalaTool(mainCls, classpath)
- val outDir = buildDirectory.value / "quick/bin"
- writeScripts(scalaTool, file, outDir)
- }
-
- def mkPackBin(file: String, mainCls: String): Seq[File] = {
- val scalaTool = mkScalaTool(mainCls, classpath = Nil)
- val outDir = buildDirectory.value / "pack/bin"
- writeScripts(scalaTool, file, outDir)
+ res.foreach { f =>
+ if(!f.getAbsoluteFile.setExecutable(true, /* ownerOnly: */ false))
+ throw new IOException("setExecutable failed")
+ if(!f.getAbsoluteFile.setReadable(true, /* ownerOnly: */ false))
+ throw new IOException("setReadable failed")
+ }
+ res
}
def mkBin(file: String, mainCls: String, classpath: Seq[Attributed[File]]): Seq[File] =
- mkQuickBin(file, mainCls, classpath) ++ mkPackBin(file, mainCls)
+ writeScripts(mkScalaTool(mainCls, classpath), file, quickOutDir) ++
+ writeScripts(mkScalaTool(mainCls, Nil ), file, packOutDir)
- mkBin("scala" , "scala.tools.nsc.MainGenericRunner", (fullClasspath in Compile in repl).value) ++
+ streams.value.log.info(s"Creating scripts in $quickOutDir and $packOutDir")
+
+ mkBin("scala" , "scala.tools.nsc.MainGenericRunner", (fullClasspath in Compile in replJlineEmbedded).value) ++
mkBin("scalac" , "scala.tools.nsc.Main", (fullClasspath in Compile in compiler).value) ++
mkBin("fsc" , "scala.tools.nsc.CompileClient", (fullClasspath in Compile in compiler).value) ++
mkBin("scaladoc" , "scala.tools.nsc.ScalaDoc", (fullClasspath in Compile in scaladoc).value) ++
mkBin("scalap" , "scala.tools.scalap.Main", (fullClasspath in Compile in scalap).value)
}
+/** Generate service provider definition files under META-INF/services */
+def generateServiceProviderResources(services: (String, String)*): Setting[_] =
+ resourceGenerators in Compile += Def.task {
+ services.map { case (k, v) =>
+ val f = (resourceManaged in Compile).value / "META-INF/services" / k
+ IO.write(f, v + "\n")
+ f
+ }
+ }.taskValue
+
buildDirectory in ThisBuild := (baseDirectory in ThisBuild).value / "build-sbt"
-lazy val versionProps: Map[String, String] = {
- import java.io.FileInputStream
- import java.util.Properties
- val props = new Properties()
- val in = new FileInputStream(file("versions.properties"))
- try props.load(in)
- finally in.close()
- import scala.collection.JavaConverters._
- props.asScala.toMap
+// Add tab completion to partest
+commands += Command("partest")(_ => PartestUtil.partestParser((baseDirectory in ThisBuild).value, (baseDirectory in ThisBuild).value / "test")) { (state, parsed) =>
+ ("test/it:testOnly -- " + parsed) :: state
+}
+
+// Add tab completion to scalac et al.
+commands ++= {
+ val commands =
+ List(("scalac", "compiler", "scala.tools.nsc.Main"),
+ ("scala", "repl-jline-embedded", "scala.tools.nsc.MainGenericRunner"),
+ ("scaladoc", "scaladoc", "scala.tools.nsc.ScalaDoc"))
+
+ commands.map {
+ case (entryPoint, projectRef, mainClassName) =>
+ Command(entryPoint)(_ => ScalaOptionParser.scalaParser(entryPoint, (baseDirectory in ThisBuild).value)) { (state, parsedOptions) =>
+ (projectRef + "/runMain " + mainClassName + " -usejavacp " + parsedOptions) :: state
+ }
+ }
}
-def versionNumber(name: String): String =
- versionProps(s"$name.version.number")
+addCommandAlias("scalap", "scalap/compile:runMain scala.tools.scalap.Main -usejavacp")
diff --git a/build.xml b/build.xml
index 7f8c91b47b..7b49544447 100644
--- a/build.xml
+++ b/build.xml
@@ -184,7 +184,7 @@ TODO:
<property name="dists.dir" value="${basedir}/dists"/>
- <property name="copyright.string" value="Copyright 2002-2015, LAMP/EPFL"/>
+ <property name="copyright.string" value="Copyright 2002-2016, LAMP/EPFL"/>
<!-- These are NOT the flags used to run SuperSabbus, but the ones written
into the script runners created with scala.tools.ant.ScalaTool -->
@@ -535,6 +535,8 @@ TODO:
<property name="scalac.args.quick" value="${scalac.args.all}"/>
<property name="scalac.args.strap" value="${scalac.args.quick}"/>
+ <property name="partest.scalac_opts" value=""/> <!-- set default value, otherwise the property name will be passed to partest if undefined -->
+
<!-- This is the start time for the distribution -->
<tstamp prefix="time">
<format property="human" pattern="d MMMM yyyy, HH:mm:ss" locale="en,US"/>
@@ -1642,7 +1644,7 @@ TODO:
<mkdir dir="${bc-build.dir}"/>
<!-- Pull down MIMA -->
<artifact:dependencies pathId="mima.classpath">
- <dependency groupId="com.typesafe" artifactId="mima-reporter_2.10" version="0.1.6"/>
+ <dependency groupId="com.typesafe" artifactId="mima-reporter_2.10" version="0.1.8"/>
</artifact:dependencies>
<artifact:dependencies pathId="old.bc.classpath">
<dependency groupId="org.scala-lang" artifactId="scala-library" version="${bc-reference-version}"/>
@@ -1684,20 +1686,15 @@ TODO:
<target name="docs.lib" depends="docs.start" unless="docs.skip">
<staged-docs project="library">
<include name="**/*.scala"/>
- <exclude name="runtime/*$.scala"/>
- <exclude name="runtime/ScalaRunTime.scala"/>
- <exclude name="runtime/StringAdd.scala"/>
+ <exclude name="**/runtime/*$.scala"/>
+ <exclude name="**/runtime/ScalaRunTime.scala"/>
+ <exclude name="**/runtime/StringAdd.scala"/>
</staged-docs>
</target>
<target name="docs.reflect" depends="docs.start" unless="docs.skip">
<staged-docs project="reflect">
<include name="**/*.scala"/>
- <exclude name="reflect/Code.scala"/>
- <exclude name="reflect/Print.scala"/>
- <exclude name="reflect/Symbol.scala"/>
- <exclude name="reflect/Tree.scala"/>
- <exclude name="reflect/Type.scala"/>
</staged-docs>
</target>
diff --git a/doc/LICENSE.md b/doc/LICENSE.md
index 55e82f64ba..c56b38daa2 100644
--- a/doc/LICENSE.md
+++ b/doc/LICENSE.md
@@ -2,9 +2,9 @@ Scala is licensed under the [BSD 3-Clause License](http://opensource.org/license
## Scala License
-Copyright (c) 2002-2015 EPFL
+Copyright (c) 2002-2016 EPFL
-Copyright (c) 2011-2015 Typesafe, Inc.
+Copyright (c) 2011-2016 Lightbend, Inc.
All rights reserved.
diff --git a/doc/License.rtf b/doc/License.rtf
index c475bda3ef..c8f24838a2 100644
--- a/doc/License.rtf
+++ b/doc/License.rtf
@@ -10,8 +10,8 @@
\fs48 Scala License
\fs40 \
-\fs26 Copyright (c) 2002-2015 EPFL\
-Copyright (c) 2011-2015 Typesafe, Inc.\
+\fs26 Copyright (c) 2002-2016 EPFL\
+Copyright (c) 2011-2016 Lightbend, Inc.\
All rights reserved.\
\
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\
diff --git a/project/JarJar.scala b/project/JarJar.scala
new file mode 100644
index 0000000000..918060c9ee
--- /dev/null
+++ b/project/JarJar.scala
@@ -0,0 +1,92 @@
+import org.pantsbuild.jarjar
+import org.pantsbuild.jarjar._
+import org.pantsbuild.jarjar.util._
+import scala.collection.JavaConverters._
+import java.util.jar._
+import java.io._
+import sbt._
+
+object JarJar {
+ sealed abstract class JarJarConfig {
+ def toPatternElement: PatternElement
+ }
+ object JarJarConfig {
+ case class Rule(pattern: String, result: String) extends JarJarConfig {
+ def toPatternElement: PatternElement = {
+ val rule = new jarjar.Rule
+ rule.setPattern(pattern)
+ rule.setResult(result)
+ rule
+ }
+ }
+ case class Keep(pattern: String) extends JarJarConfig {
+ def toPatternElement: PatternElement = {
+ val keep = new jarjar.Keep
+ keep.setPattern(pattern)
+ keep
+ }
+ }
+ }
+
+ sealed abstract class Entry {
+ def name: String
+ def time: Long
+ def data: Array[Byte]
+ }
+
+ case class JarEntryInput(jarFile: JarFile, entry: JarEntry) extends Entry {
+ def name = entry.getName.replace('\\', '/')
+ def time = entry.getTime
+ def data = sbt.IO.readBytes(jarFile.getInputStream(entry))
+ }
+ case class FileInput(base: File, file: File) extends Entry {
+ def name = file.relativeTo(base).get.getPath.replace('\\', '/')
+ def time = file.lastModified
+ def data = sbt.IO.readBytes(file)
+ }
+
+ private def newMainProcessor(patterns: java.util.List[PatternElement], verbose: Boolean, skipManifest: Boolean): JarProcessor = {
+ val cls = Class.forName("org.pantsbuild.jarjar.MainProcessor")
+ val constructor = cls.getConstructor(classOf[java.util.List[_]], java.lang.Boolean.TYPE, java.lang.Boolean.TYPE)
+ constructor.setAccessible(true)
+ constructor.newInstance(patterns, Boolean.box(verbose), Boolean.box(skipManifest)).asInstanceOf[JarProcessor]
+ }
+
+ def apply(in: Iterator[Entry], outdir: File,
+ config: Seq[JarJarConfig], verbose: Boolean = false): Seq[File] = {
+ val patterns = config.map(_.toPatternElement).asJava
+ val processor = newMainProcessor(patterns, verbose, false)
+ def process(e: Entry): Option[File] = {
+ val struct = new EntryStruct()
+ struct.name = e.name
+ struct.time = e.time
+ struct.data = e.data
+ if (processor.process(struct)) {
+ if (struct.name.endsWith("/")) None
+ else {
+ val f = outdir / struct.name
+ try {
+ f.getParentFile.mkdirs()
+ sbt.IO.write(f, struct.data)
+ } catch {
+ case ex: Exception =>
+ throw new IOException(s"Failed to write ${e.name} / ${f.getParentFile} / ${f.getParentFile.exists}", ex)
+ }
+ Some(f)
+ }
+ }
+ else None
+ }
+ val processed = in.flatMap(entry => process(entry)).toSet
+ val getter = processor.getClass.getDeclaredMethod("getExcludes")
+ getter.setAccessible(true)
+ val excludes = getter.invoke(processor).asInstanceOf[java.util.Set[String]].asScala
+ val excluded = excludes.map { name =>
+ val f: File = outdir / name
+ if(f.exists && !f.delete())
+ throw new IOException("Failed to delete excluded file $f")
+ f
+ }
+ (processed -- excluded).toSeq
+ }
+}
diff --git a/project/Osgi.scala b/project/Osgi.scala
new file mode 100644
index 0000000000..ed961d1c27
--- /dev/null
+++ b/project/Osgi.scala
@@ -0,0 +1,69 @@
+import aQute.lib.osgi.Builder
+import aQute.lib.osgi.Constants._
+import java.util.Properties
+import sbt._
+import sbt.Keys._
+import scala.collection.JavaConversions._
+import VersionUtil.versionProperties
+
+/** OSGi packaging for the Scala build, distilled from sbt-osgi. We do not use sbt-osgi because it
+ * depends on a newer version of BND which gives slightly different output (probably OK to upgrade
+ * in the future but for now it would make comparing the sbt and ant build output harder) and does
+ * not allow a crucial bit of configuration that we need: Setting the classpath for BND. In sbt-osgi
+ * this is always `fullClasspath in Compile` whereas we want `products in Compile in packageBin`. */
+object Osgi {
+ val bundle = TaskKey[File]("osgiBundle", "Create an OSGi bundle.")
+ val bundleName = SettingKey[String]("osgiBundleName", "The Bundle-Name for the manifest.")
+ val bundleSymbolicName = SettingKey[String]("osgiBundleSymbolicName", "The Bundle-SymbolicName for the manifest.")
+ val headers = SettingKey[Seq[(String, String)]]("osgiHeaders", "Headers and processing instructions for BND.")
+
+ def settings: Seq[Setting[_]] = Seq(
+ bundleName := description.value,
+ bundleSymbolicName := organization.value + "." + name.value,
+ headers := {
+ val v = VersionUtil.versionProperties.value.osgiVersion
+ Seq(
+ "Bundle-Name" -> bundleName.value,
+ "Bundle-SymbolicName" -> bundleSymbolicName.value,
+ "ver" -> v,
+ "Export-Package" -> ("*;version=${ver}"),
+ "Import-Package" -> ("scala.*;version=\"${range;[==,=+);${ver}}\",*"),
+ "Bundle-Version" -> v,
+ "Bundle-RequiredExecutionEnvironment" -> "JavaSE-1.6, JavaSE-1.7",
+ "-eclipse" -> "false"
+ )
+ },
+ bundle <<= Def.task {
+ bundleTask(headers.value.toMap, (products in Compile in packageBin).value,
+ (artifactPath in (Compile, packageBin)).value, Nil, streams.value)
+ },
+ packagedArtifact in (Compile, packageBin) <<= (artifact in (Compile, packageBin), bundle).identityMap,
+ // Also create OSGi source bundles:
+ artifact in (Compile, packageBin) ~= (_.copy(`type` = "bundle")),
+ packageOptions in (Compile, packageSrc) += Package.ManifestAttributes(
+ "Bundle-Name" -> (description.value + " Sources"),
+ "Bundle-SymbolicName" -> (bundleSymbolicName.value + ".source"),
+ "Bundle-Version" -> versionProperties.value.osgiVersion,
+ "Eclipse-SourceBundle" -> (bundleSymbolicName.value + ";version=\"" + versionProperties.value.osgiVersion + "\";roots:=\".\"")
+ )
+ )
+
+ def bundleTask(headers: Map[String, String], fullClasspath: Seq[File], artifactPath: File,
+ resourceDirectories: Seq[File], streams: TaskStreams): File = {
+ val log = streams.log
+ val builder = new Builder
+ builder.setClasspath(fullClasspath.toArray)
+ headers foreach { case (k, v) => builder.setProperty(k, v) }
+ val includeRes = resourceDirectories.filter(_.exists).map(_.getAbsolutePath).mkString(",")
+ if(!includeRes.isEmpty) builder.setProperty(INCLUDERESOURCE, includeRes)
+ builder.getProperties.foreach { case (k, v) => log.debug(s"bnd: $k: $v") }
+ // builder.build is not thread-safe because it uses a static SimpleDateFormat. This ensures
+ // that all calls to builder.build are serialized.
+ val jar = synchronized { builder.build }
+ builder.getWarnings.foreach(s => log.warn(s"bnd: $s"))
+ builder.getErrors.foreach(s => log.error(s"bnd: $s"))
+ IO.createDirectory(artifactPath.getParentFile)
+ jar.write(artifactPath)
+ artifactPath
+ }
+}
diff --git a/project/ParserUtil.scala b/project/ParserUtil.scala
new file mode 100644
index 0000000000..cdaf8831a5
--- /dev/null
+++ b/project/ParserUtil.scala
@@ -0,0 +1,52 @@
+import sbt._
+import sbt.complete.Parser._
+import sbt.complete.Parsers._
+import sbt.complete._
+
+object ParserUtil {
+ def notStartingWith(parser: Parser[String], c: Char): Parser[String] = parser & not(c ~> any.*, "value cannot start with " + c + ".")
+ def concat(p: Parser[(String, String)]): Parser[String] = {
+ p.map(x => x._1 + x._2)
+ }
+
+ def Opt(a: Parser[String]) = a.?.map(_.getOrElse(""))
+
+ val StringBasicNotStartingWithDash = notStartingWith(StringBasic, '-')
+ val IsDirectoryFilter = new SimpleFileFilter(_.isDirectory)
+ val JarOrDirectoryParser = FileParser(GlobFilter("*.jar") || IsDirectoryFilter)
+ def FileParser(fileFilter: FileFilter, dirFilter: FileFilter = AllPassFilter, base: File = file(".")) = {
+ def matching(prefix: String): List[String] = {
+ val preFile = file(prefix)
+ val cwd = base
+ val parent = Option(preFile.getParentFile).getOrElse(cwd)
+ if (preFile.exists) {
+ if (preFile.isDirectory) {
+ preFile.*(IsDirectoryFilter.&&(dirFilter) || fileFilter).get.map(_.getPath).toList
+ } else {
+ List(preFile).filter(fileFilter.accept).map(_.getPath)
+ }
+ }
+ else if (parent != null) {
+ def ensureSuffix(s: String, suffix: String) = if (s.endsWith(suffix)) s else s + suffix
+ def pathOf(f: File): String = {
+ val f1 = if (preFile.getParentFile == null) f.relativeTo(cwd).getOrElse(f) else f
+ if (f1.isDirectory && !fileFilter.accept(f1)) ensureSuffix(f1.getPath, "/") else f1.getPath
+ }
+ val childFilter = GlobFilter(preFile.name + "*") && ((IsDirectoryFilter && dirFilter) || fileFilter)
+ val children = parent.*(childFilter).get
+ children.map(pathOf).toList
+ } else Nil
+ }
+ def displayPath = Completions.single(Completion.displayOnly("<path>"))
+ token(StringBasic, TokenCompletions.fixed((seen, level) => if (seen.isEmpty) displayPath else matching(seen) match {
+ case Nil => displayPath
+ case x :: Nil =>
+ if (fileFilter.accept(file(x)))
+ Completions.strict(Set(Completion.tokenDisplay(x.stripPrefix(seen), x)))
+ else
+ Completions.strict(Set(Completion.suggestion(x.stripPrefix(seen))))
+ case xs =>
+ Completions.strict(xs.map(x => Completion.tokenDisplay(x.stripPrefix(seen), x)).toSet)
+ })).filter(!_.startsWith("-"), x => x)
+ }
+} \ No newline at end of file
diff --git a/project/PartestUtil.scala b/project/PartestUtil.scala
new file mode 100644
index 0000000000..4b18c94b47
--- /dev/null
+++ b/project/PartestUtil.scala
@@ -0,0 +1,92 @@
+import sbt._
+import sbt.complete._, Parser._, Parsers._
+
+object PartestUtil {
+ private case class TestFiles(srcPath: String, globalBase: File, testBase: File) {
+ private val testCaseDir = new SimpleFileFilter(f => f.isDirectory && f.listFiles.nonEmpty && !(f.getParentFile / (f.name + ".res")).exists)
+ private val testCaseFilter = GlobFilter("*.scala") | GlobFilter("*.java") | GlobFilter("*.res") || testCaseDir
+ private def testCaseFinder = (testBase / srcPath).*(AllPassFilter).*(testCaseFilter)
+ private val basePaths = allTestCases.map(_._2.split('/').take(3).mkString("/") + "/").distinct
+
+ def allTestCases = testCaseFinder.pair(relativeTo(globalBase))
+ def basePathExamples = new FixedSetExamples(basePaths)
+ private def equiv(f1: File, f2: File) = f1.getCanonicalFile == f2.getCanonicalFile
+ def parentChain(f: File): Iterator[File] =
+ if (f == null || !f.exists) Iterator()
+ else Iterator(f) ++ (if (f.getParentFile == null) Nil else parentChain(f.getParentFile))
+ def isParentOf(parent: File, f2: File, maxDepth: Int) =
+ parentChain(f2).take(maxDepth).exists(p1 => equiv(p1, parent))
+ def isTestCase(f: File) = {
+ val grandParent = if (f != null && f.getParentFile != null) f.getParentFile.getParentFile else null
+ grandParent != null && equiv(grandParent, testBase / srcPath) && testCaseFilter.accept(f)
+ }
+ def mayContainTestCase(f: File) = {
+ isParentOf(testBase / srcPath, f, 2) || isParentOf(f, testBase / srcPath, Int.MaxValue)
+ }
+ }
+ /** A parser for the custom `partest` command */
+ def partestParser(globalBase: File, testBase: File): Parser[String] = {
+ val knownUnaryOptions = List(
+ "--pos", "--neg", "--run", "--jvm", "--res", "--ant", "--scalap", "--specialized",
+ "--scalacheck", "--instrumented", "--presentation", "--failed", "--update-check",
+ "--show-diff", "--verbose", "--terse", "--debug", "--version", "--self-test", "--help")
+ val srcPathOption = "--srcpath"
+ val grepOption = "--grep"
+
+ // HACK: if we parse `--srpath scaladoc`, we overwrite this var. The parser for test file paths
+ // then lazily creates the examples based on the current value.
+ // TODO is there a cleaner way to do this with SBT's parser infrastructure?
+ var srcPath = "files"
+ var _testFiles: TestFiles = null
+ def testFiles = {
+ if (_testFiles == null || _testFiles.srcPath != srcPath) _testFiles = new TestFiles(srcPath, globalBase, testBase)
+ _testFiles
+ }
+ val TestPathParser = ParserUtil.FileParser(
+ new SimpleFileFilter(f => testFiles.isTestCase(f)),
+ new SimpleFileFilter(f => testFiles.mayContainTestCase(f)), globalBase)
+
+ // allow `--grep "is unchecked" | --grep *t123*, in the spirit of ./bin/partest-ack
+ // superset of the --grep built into partest itself.
+ val Grep = {
+ def expandGrep(x: String): Seq[String] = {
+ val matchingFileContent = try {
+ val Pattern = ("(?i)" + x).r
+ testFiles.allTestCases.filter {
+ case (testFile, testPath) =>
+ val assocFiles = List(".check", ".flags").map(testFile.getParentFile / _)
+ val sourceFiles = if (testFile.isFile) List(testFile) else testFile.**(AllPassFilter).get.toList
+ val allFiles = testFile :: assocFiles ::: sourceFiles
+ allFiles.exists { f => f.exists && f.isFile && Pattern.findFirstIn(IO.read(f)).isDefined }
+ }
+ } catch {
+ case _: Throwable => Nil
+ }
+ val matchingFileName = try {
+ val filter = GlobFilter("*" + x + "*")
+ testFiles.allTestCases.filter(x => filter.accept(x._1.name))
+ } catch {
+ case t: Throwable => Nil
+ }
+ (matchingFileContent ++ matchingFileName).map(_._2).distinct.sorted
+ }
+
+ val completion = Completions.strict(Set("<filename glob>", "<regex> (for source, flags or checkfile contents)").map(s => Completion.displayOnly(s)))
+ val tokenCompletion = TokenCompletions.fixed((seen, level) => completion)
+
+ val globOrPattern = StringBasic.map(expandGrep).flatMap {
+ case Seq() => failure("no tests match pattern / glob")
+ case x => success(x.mkString(" "))
+ }
+ token(grepOption <~ Space) ~> token(globOrPattern, tokenCompletion)
+ }
+
+ val SrcPath = ((token(srcPathOption) <~ Space) ~ token(StringBasic.examples(Set("files", "pending", "scaladoc")))) map {
+ case opt ~ path =>
+ srcPath = path
+ opt + " " + path
+ }
+ val P = oneOf(knownUnaryOptions.map(x => token(x))) | SrcPath | TestPathParser | Grep
+ (Space ~> repsep(P, oneOrMore(Space))).map(_.mkString(" ")).?.map(_.getOrElse("")) <~ OptSpace
+ }
+}
diff --git a/project/ScalaOptionParser.scala b/project/ScalaOptionParser.scala
new file mode 100644
index 0000000000..da8a3bf460
--- /dev/null
+++ b/project/ScalaOptionParser.scala
@@ -0,0 +1,129 @@
+import ParserUtil._
+import sbt._
+import sbt.complete.Parser._
+import sbt.complete.Parsers._
+import sbt.complete._
+
+object ScalaOptionParser {
+ /** A SBT parser for the Scala command line runners (scala, scalac, etc) */
+ def scalaParser(entryPoint: String, globalBase: File): Parser[String] = {
+ def BooleanSetting(name: String): Parser[String] =
+ token(name)
+ def StringSetting(name: String): Parser[String] = {
+ val valueParser = name match {
+ case "-d" => JarOrDirectoryParser
+ case _ => token(StringBasic, TokenCompletions.displayOnly("<value>"))
+ }
+ concat(concat(token(name ~ Space.string)) ~ valueParser)
+ }
+ def MultiStringSetting(name: String): Parser[String] =
+ concat(concat(token(name ~ ":")) ~ repsep(token(StringBasicNotStartingWithDash, TokenCompletions.displayOnly("<value>")), token(",")).map(_.mkString))
+ def IntSetting(name: String): Parser[String] =
+ concat(concat(token(name ~ ":")) ~ token(IntBasic.map(_.toString), TokenCompletions.displayOnly("<integer>")))
+ def ChoiceSetting(name: String, choices: List[String]): Parser[String] =
+ concat(token(concat(name ~ ":")) ~ token(StringBasic.examples(choices: _*)).map(_.mkString))
+ def MultiChoiceSetting(name: String, choices: List[String]): Parser[String] =
+ concat(token(concat(name ~ ":")) ~ rep1sep(token(StringBasic.examples(choices: _*)), token(",")).map(_.mkString))
+ def PathSetting(name: String): Parser[String] = {
+ concat(concat(token(name) ~ Space.string) ~ rep1sep(JarOrDirectoryParser.filter(!_.contains(":"), x => x), token(java.io.File.pathSeparator)).map(_.mkString))
+ }
+ def FileSetting(name: String): Parser[String] = {
+ concat(concat(token(name) ~ Space.string) ~ rep1sep(JarOrDirectoryParser.filter(!_.contains(":"), x => x), token(java.io.File.pathSeparator)).map(_.mkString))
+ }
+ val Phase = token(NotSpace.examples(phases: _*))
+ def PhaseSettingParser(name: String): Parser[String] = {
+ MultiChoiceSetting(name, phases)
+ }
+ def ScalaVersionSetting(name: String): Parser[String] = {
+ concat(concat(token(name ~ Space.string)) ~ token(StringBasic, TokenCompletions.displayOnly("<scala version>")))
+ }
+ val Property: Parser[String] = {
+ val PropName = concat(token("-D" ~ oneOrMore(NotSpaceClass & not('=', "not =")).string, TokenCompletions.displayOnly("-D<property name>")))
+ val EqualsValue = concat("=" ~ token(OptNotSpace, TokenCompletions.displayOnly("<property value>")))
+ concat(PropName ~ EqualsValue.?.map(_.getOrElse("")))
+ }
+
+ val sourceFile = FileParser(GlobFilter("*.scala") | GlobFilter("*.java"))
+
+ // TODO Allow JVM settings via -J-... and temporarily add them to the ForkOptions
+ val UniversalOpt = Property | oneOf(pathSettingNames.map(PathSetting) ++ phaseSettings.map(PhaseSettingParser) ++ booleanSettingNames.map(BooleanSetting) ++ stringSettingNames.map(StringSetting) ++ multiStringSettingNames.map(MultiStringSetting) ++ intSettingNames.map(IntSetting) ++ choiceSettingNames.map { case (k, v) => ChoiceSetting(k, v) } ++ multiChoiceSettingNames.map { case (k, v) => MultiChoiceSetting(k, v) } ++ scalaVersionSettings.map(ScalaVersionSetting))
+ val ScalacOpt = sourceFile | UniversalOpt
+
+ val ScalaExtraSettings = oneOf(
+ scalaChoiceSettingNames.map { case (k, v) => ChoiceSetting(k,v)}.toList
+ ++ scalaStringSettingNames.map(StringSetting)
+ ++ scalaBooleanSettingNames.map(BooleanSetting))
+ val ScalaOpt = UniversalOpt | ScalaExtraSettings
+
+ val ScalaDocExtraSettings = oneOf(
+ scalaDocBooleanSettingNames.map(BooleanSetting)
+ ++ scalaDocIntSettingNames.map(IntSetting)
+ ++ scalaDocChoiceSettingNames.map { case (k, v) => ChoiceSetting(k, v)}
+ ++ scaladocStringSettingNames.map(StringSetting)
+ ++ scaladocPathSettingNames.map(PathSetting)
+ ++ scaladocMultiStringSettingNames.map(MultiStringSetting)
+ )
+ val ScalaDocOpt = ScalacOpt | ScalaDocExtraSettings
+
+ val P = entryPoint match {
+ case "scala" =>
+ val runnable = token(StringBasicNotStartingWithDash, TokenCompletions.displayOnly("<script|class|object|jar>")).filter(!_.startsWith("-"), x => x)
+ val runnableAndArgs = concat(runnable ~ Opt(concat(Space.string ~ repsep(token(StringBasic, TokenCompletions.displayOnly("<arg>")), Space).map(_.mkString(" ")))))
+ val options = rep1sep(ScalaOpt, Space).map(_.mkString(" "))
+ Opt(Space ~> (options | concat(concat(options ~ Space.string) ~ runnableAndArgs) | runnableAndArgs))
+ case "scaladoc" =>
+ Opt(Space ~> Opt(repsep(ScalaDocOpt, Space).map(_.mkString(" "))))
+ case "scalac" =>
+ Opt(Space ~> repsep(ScalacOpt, Space).map(_.mkString(" ")))
+ }
+ P <~ token(OptSpace)
+ }
+
+ // TODO retrieve this data programatically, ala https://github.com/scala/scala-tool-support/blob/master/bash-completion/src/main/scala/BashCompletion.scala
+ private def booleanSettingNames = List("-X", "-Xcheckinit", "-Xdev", "-Xdisable-assertions", "-Xexperimental", "-Xfatal-warnings", "-Xfull-lubs", "-Xfuture", "-Xlog-free-terms", "-Xlog-free-types", "-Xlog-implicit-conversions", "-Xlog-implicits", "-Xlog-reflective-calls",
+ "-Xno-forwarders", "-Xno-patmat-analysis", "-Xno-uescape", "-Xnojline", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xstrict-inference", "-Xverify", "-Y",
+ "-Ybreak-cycles", "-Yclosure-elim", "-Yconst-opt", "-Ydead-code", "-Ydebug", "-Ycompact-trees", "-Ydisable-unreachable-prevention", "-YdisableFlatCpCaching", "-Ydoc-debug",
+ "-Yeta-expand-keeps-star", "-Yide-debug", "-Yinfer-argument-types", "-Yinfer-by-name", "-Yinfer-debug", "-Yinline", "-Yinline-handlers",
+ "-Yinline-warnings", "-Yissue-debug", "-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand",
+ "-Yno-completion", "-Yno-generic-signatures", "-Yno-imports", "-Yno-load-impl-class", "-Yno-predef", "-Ynooptimise",
+ "-Yoverride-objects", "-Yoverride-vars", "-Ypatmat-debug", "-Yno-adapted-args", "-Ypos-debug", "-Ypresentation-debug",
+ "-Ypresentation-strict", "-Ypresentation-verbose", "-Yquasiquote-debug", "-Yrangepos", "-Yreify-copypaste", "-Yreify-debug", "-Yrepl-class-based",
+ "-Yrepl-sync", "-Yshow-member-pos", "-Yshow-symkinds", "-Yshow-symowners", "-Yshow-syms", "-Yshow-trees", "-Yshow-trees-compact", "-Yshow-trees-stringified", "-Ytyper-debug",
+ "-Ywarn-adapted-args", "-Ywarn-dead-code", "-Ywarn-inaccessible", "-Ywarn-infer-any", "-Ywarn-nullary-override", "-Ywarn-nullary-unit", "-Ywarn-numeric-widen", "-Ywarn-unused", "-Ywarn-unused-import", "-Ywarn-value-discard",
+ "-deprecation", "-explaintypes", "-feature", "-help", "-no-specialization", "-nobootcp", "-nowarn", "-optimise", "-print", "-unchecked", "-uniqid", "-usejavacp", "-usemanifestcp", "-verbose", "-version")
+ private def stringSettingNames = List("-Xgenerate-phase-graph", "-Xmain-class", "-Xpluginsdir", "-Xshow-class", "-Xshow-object", "-Xsource-reader", "-Ydump-classes", "-Ygen-asmp",
+ "-Ygen-javap", "-Ypresentation-log", "-Ypresentation-replay", "-Yrepl-outdir", "-d", "-dependencyfile", "-encoding", "-Xscript")
+ private def pathSettingNames = List("-bootclasspath", "-classpath", "-extdirs", "-javabootclasspath", "-javaextdirs", "-sourcepath", "-toolcp")
+ private val phases = List("all", "parser", "namer", "packageobjects", "typer", "patmat", "superaccessors", "extmethods", "pickler", "refchecks", "uncurry", "tailcalls", "specialize", "explicitouter", "erasure", "posterasure", "lazyvals", "lambdalift", "constructors", "flatten", "mixin", "cleanup", "delambdafy", "icode", "jvm", "terminal")
+ private val phaseSettings = List("-Xprint-icode", "-Ystop-after", "-Yskip", "-Yshow", "-Ystop-before", "-Ybrowse", "-Ylog", "-Ycheck", "-Xprint")
+ private def multiStringSettingNames = List("-Xmacro-settings", "-Xplugin", "-Xplugin-disable", "-Xplugin-require")
+ private def intSettingNames = List("-Xmax-classfile-name", "-Xelide-below", "-Ypatmat-exhaust-depth", "-Ypresentation-delay", "-Yrecursion")
+ private def choiceSettingNames = Map[String, List[String]](
+ "-Ybackend" -> List("GenASM", "GenBCode"),
+ "-YclasspathImpl" -> List("flat", "recursive"),
+ "-Ydelambdafy" -> List("inline", "method"),
+ "-Ylinearizer" -> List("dfs", "dump", "normal", "rpo"),
+ "-Ymacro-expand" -> List("discard", "none"),
+ "-Yresolve-term-conflict" -> List("error", "object", "package"),
+ "-g" -> List("line", "none", "notailcails", "source", "vars"),
+ "-target" -> List("jvm-1.5", "jvm-1.6", "jvm-1.7", "jvm-1.8"))
+ private def multiChoiceSettingNames = Map[String, List[String]](
+ "-Xlint" -> List("adapted-args", "nullary-unit", "inaccessible", "nullary-override", "infer-any", "missing-interpolator", "doc-detached", "private-shadow", "type-parameter-shadow", "poly-implicit-overload", "option-implicit", "delayedinit-select", "by-name-right-associative", "package-object-classes", "unsound-match", "stars-align"),
+ "-language" -> List("help", "_", "dynamics", "postfixOps", "reflectiveCalls", "implicitConversions", "higherKinds", "existentials", "experimental.macros"),
+ "-Yopt" -> List("l:none", "l:default", "l:method", "l:project", "l:classpath", "unreachable-code", "simplify-jumps", "empty-line-numbers", "empty-labels", "compact-locals", "nullness-tracking", "closure-elimination", "inline-project", "inline-global"),
+ "-Ystatistics" -> List("parser", "typer", "patmat", "erasure", "cleanup", "jvm")
+ )
+ private def scalaVersionSettings = List("-Xmigration", "-Xsource")
+
+ private def scalaChoiceSettingNames = Map("-howtorun" -> List("object", "script", "jar", "guess"))
+ private def scalaStringSettingNames = List("-i", "-e")
+ private def scalaBooleanSettingNames = List("-nc", "-save")
+
+ private def scalaDocBooleanSettingNames = List("-Yuse-stupid-types", "-implicits", "-implicits-debug", "-implicits-show-all", "-implicits-sound-shadowing", "-implicits-hide", "-author", "-diagrams", "-diagrams-debug", "-raw-output", "-no-prefixes", "-no-link-warnings", "-expand-all-types", "-groups")
+ private def scalaDocIntSettingNames = List("-diagrams-max-classes", "-diagrams-max-implicits", "-diagrams-dot-timeout", "-diagrams-dot-restart")
+ private def scalaDocChoiceSettingNames = Map("-doc-format" -> List("html"))
+ private def scaladocStringSettingNames = List("-doc-title", "-doc-version", "-doc-footer", "-doc-no-compile", "-doc-source-url", "-doc-generator", "-skip-packages")
+ private def scaladocPathSettingNames = List("-doc-root-content", "-diagrams-dot-path")
+ private def scaladocMultiStringSettingNames = List("-doc-external-doc")
+
+}
diff --git a/project/ScalaTool.scala b/project/ScalaTool.scala
index 559b215c18..e9531f229e 100644
--- a/project/ScalaTool.scala
+++ b/project/ScalaTool.scala
@@ -1,4 +1,5 @@
import sbt._
+import org.apache.commons.lang3.SystemUtils
import org.apache.commons.lang3.StringUtils.replaceEach
/**
@@ -15,8 +16,15 @@ case class ScalaTool(mainClass: String,
// demarcation of any script variables (e.g. `${SCALA_HOME}` or
// `%SCALA_HOME%`) can be specified in a platform independent way (e.g.
// `@SCALA_HOME@`) and automatically translated for you.
- def patchedToolScript(template: String, platform: String) = {
+ def patchedToolScript(template: String, forWindows: Boolean) = {
val varRegex = """@(\w+)@""" // the group should be able to capture each of the keys of the map below
+ val platformClasspath =
+ if(forWindows) classpath.mkString(";").replace('/', '\\').replaceAll(varRegex, "%$1%")
+ else if(SystemUtils.IS_OS_WINDOWS) {
+ // When building on Windows, use a Windows classpath in the shell script (for MSYS/Cygwin).
+ // This is only used for "quick", which uses absolute paths, so it is not portable anyway.
+ classpath.mkString(";").replace("\\", "\\\\").replaceAll(varRegex, """\${$1}""")
+ } else classpath.mkString(":").replace('\\', '/').replaceAll(varRegex, """\${$1}""")
val variables = Map(
("@@" -> "@"), // for backwards compatibility
@@ -24,10 +32,7 @@ case class ScalaTool(mainClass: String,
("@properties@" -> (properties map { case (k, v) => s"""-D$k="$v""""} mkString " ")),
("@javaflags@" -> javaOpts),
("@toolflags@" -> toolFlags),
- ("@classpath@" -> (platform match {
- case "unix" => classpath.mkString(":").replace('\\', '/').replaceAll(varRegex, """\${$1}""")
- case "windows" => classpath.mkString(";").replace('/', '\\').replaceAll(varRegex, "%$1%")
- }))
+ ("@classpath@" -> platformClasspath)
)
val (from, to) = variables.unzip
@@ -35,10 +40,12 @@ case class ScalaTool(mainClass: String,
}
def writeScript(file: String, platform: String, rootDir: File, outDir: File): File = {
+ val forWindows = platform match { case "windows" => true case _ => false }
val templatePath = s"scala/tools/ant/templates/tool-$platform.tmpl"
- val suffix = platform match { case "windows" => ".bat" case _ => "" }
+ val suffix = if(forWindows) ".bat" else ""
val scriptFile = outDir / s"$file$suffix"
- IO.write(scriptFile, patchedToolScript(IO.read(rootDir / templatePath), platform))
+ val patched = patchedToolScript(IO.read(rootDir / templatePath).replace("\r", ""), forWindows)
+ IO.write(scriptFile, if(forWindows) patched.replace("\n", "\r\n") else patched)
scriptFile
}
}
diff --git a/project/ScriptCommands.scala b/project/ScriptCommands.scala
new file mode 100644
index 0000000000..537990d985
--- /dev/null
+++ b/project/ScriptCommands.scala
@@ -0,0 +1,19 @@
+import sbt._
+import Keys._
+import complete.DefaultParsers._
+
+/** Custom commands for use by the Jenkins scripts. This keeps the surface area and call syntax small. */
+object ScriptCommands {
+ def all = Seq(setupPublishCore)
+
+ /** Set up the environment for `validate/publish-core`. The argument is the Artifactory snapshot repository URL. */
+ def setupPublishCore = Command.single("setupPublishCore") { case (state, url) =>
+ Project.extract(state).append(Seq(
+ VersionUtil.baseVersionSuffix in Global := "SHA-SNAPSHOT",
+ // Append build.timestamp to Artifactory URL to get consistent build numbers (see https://github.com/sbt/sbt/issues/2088):
+ publishTo in Global := Some("scala-pr" at url.replaceAll("/$", "") + ";build.timestamp=" + System.currentTimeMillis),
+ publishArtifact in (Compile, packageDoc) in ThisBuild := false,
+ scalacOptions in Compile in ThisBuild += "-optimise"
+ ), state)
+ }
+}
diff --git a/project/VersionUtil.scala b/project/VersionUtil.scala
new file mode 100644
index 0000000000..6c8aebf74f
--- /dev/null
+++ b/project/VersionUtil.scala
@@ -0,0 +1,126 @@
+import sbt._
+import Keys._
+import java.util.Properties
+import java.io.FileInputStream
+import scala.collection.JavaConverters._
+
+object VersionUtil {
+ lazy val baseVersion = settingKey[String]("The base version number from which all others are derived")
+ lazy val baseVersionSuffix = settingKey[String]("Identifies the kind of version to build")
+ lazy val copyrightString = settingKey[String]("Copyright string.")
+ lazy val versionProperties = settingKey[Versions]("Version properties.")
+ lazy val generateVersionPropertiesFile = taskKey[File]("Generating version properties file.")
+ lazy val generateBuildCharacterPropertiesFile = taskKey[File]("Generating buildcharacter.properties file.")
+
+ lazy val globalVersionSettings = Seq[Setting[_]](
+ // Set the version properties globally (they are the same for all projects)
+ versionProperties in Global := versionPropertiesImpl.value,
+ version in Global := versionProperties.value.mavenVersion
+ )
+
+ lazy val generatePropertiesFileSettings = Seq[Setting[_]](
+ copyrightString := "Copyright 2002-2016, LAMP/EPFL",
+ resourceGenerators in Compile += generateVersionPropertiesFile.map(file => Seq(file)).taskValue,
+ generateVersionPropertiesFile := generateVersionPropertiesFileImpl.value
+ )
+
+ lazy val generateBuildCharacterFileSettings = Seq[Setting[_]](
+ generateBuildCharacterPropertiesFile := generateBuildCharacterPropertiesFileImpl.value
+ )
+
+ case class Versions(canonicalVersion: String, mavenVersion: String, osgiVersion: String, commitSha: String, commitDate: String, isRelease: Boolean) {
+ val githubTree =
+ if(isRelease) "v" + mavenVersion
+ else if(commitSha != "unknown") commitSha
+ else "master"
+
+ override def toString = s"Canonical: $canonicalVersion, Maven: $mavenVersion, OSGi: $osgiVersion, github: $githubTree"
+
+ def toMap: Map[String, String] = Map(
+ "version.number" -> canonicalVersion,
+ "maven.version.number" -> mavenVersion,
+ "osgi.version.number" -> osgiVersion
+ )
+ }
+
+ /** Compute the canonical, Maven and OSGi version number from `baseVersion` and `baseVersionSuffix`.
+ * Examples of the generated versions:
+ *
+ * ("2.11.8", "SNAPSHOT" ) -> ("2.11.8-20151215-133023-7559aed3c5", "2.11.8-SNAPSHOT", "2.11.8.v20151215-133023-7559aed3c5")
+ * ("2.11.8", "SHA-SNAPSHOT") -> ("2.11.8-20151215-133023-7559aed3c5", "2.11.8-7559aed3c5-SNAPSHOT", "2.11.8.v20151215-133023-7559aed3c5")
+ * ("2.11.8", "" ) -> ("2.11.8", "2.11.8", "2.11.8.v20151215-133023-VFINAL-7559aed3c5")
+ * ("2.11.8", "M3" ) -> ("2.11.8-M3", "2.11.8-M3", "2.11.8.v20151215-133023-M3-7559aed3c5")
+ * ("2.11.8", "RC4" ) -> ("2.11.8-RC4", "2.11.8-RC4", "2.11.8.v20151215-133023-RC4-7559aed3c5")
+ * ("2.11.8-RC4", "SPLIT" ) -> ("2.11.8-RC4", "2.11.8-RC4", "2.11.8.v20151215-133023-RC4-7559aed3c5")
+ *
+ * A `baseVersionSuffix` of "SNAPSHOT" is the default, which is used for local snapshot builds. The PR validation
+ * job uses "SHA-SNAPSHOT". An empty suffix is used for releases. All other suffix values are treated as RC /
+ * milestone builds. The special suffix value "SPLIT" is used to split the real suffix off from `baseVersion`
+ * instead and then apply the usual logic. */
+ private lazy val versionPropertiesImpl: Def.Initialize[Versions] = Def.setting {
+
+ val (base, suffix) = {
+ val (b, s) = (baseVersion.value, baseVersionSuffix.value)
+ if(s == "SPLIT") {
+ val split = """([\w+\.]+)(-[\w+\.]+)??""".r
+ val split(b2, sOrNull) = b
+ (b2, Option(sOrNull).map(_.drop(1)).getOrElse(""))
+ } else (b, s)
+ }
+
+ def executeTool(tool: String) = {
+ val cmd =
+ if (System.getProperty("os.name").toLowerCase.contains("windows"))
+ s"cmd.exe /c tools\\$tool.bat -p"
+ else s"tools/$tool"
+ Process(cmd).lines.head
+ }
+
+ val date = executeTool("get-scala-commit-date")
+ val sha = executeTool("get-scala-commit-sha").substring(0, 7) // The script produces 10 digits at the moment
+
+ val (canonicalV, mavenV, osgiV, release) = suffix match {
+ case "SNAPSHOT" => (s"$base-$date-$sha", s"$base-SNAPSHOT", s"$base.v$date-$sha", false)
+ case "SHA-SNAPSHOT" => (s"$base-$date-$sha", s"$base-$sha-SNAPSHOT", s"$base.v$date-$sha", false)
+ case "" => (s"$base", s"$base", s"$base.v$date-VFINAL-$sha", true)
+ case suffix => (s"$base-$suffix", s"$base-$suffix", s"$base.v$date-$suffix-$sha", true)
+ }
+
+ Versions(canonicalV, mavenV, osgiV, sha, date, release)
+ }
+
+ private lazy val generateVersionPropertiesFileImpl: Def.Initialize[Task[File]] = Def.task {
+ writeProps(versionProperties.value.toMap + ("copyright.string" -> copyrightString.value),
+ (resourceManaged in Compile).value / s"${thisProject.value.id}.properties")
+ }
+
+ private lazy val generateBuildCharacterPropertiesFileImpl: Def.Initialize[Task[File]] = Def.task {
+ writeProps(versionProperties.value.toMap, (baseDirectory in ThisBuild).value / "buildcharacter.properties")
+ }
+
+ private def writeProps(m: Map[String, String], propFile: File): File = {
+ val props = new Properties
+ m.foreach { case (k, v) => props.put(k, v) }
+ // unfortunately, this will write properties in arbitrary order
+ // this makes it harder to test for stability of generated artifacts
+ // consider using https://github.com/etiennestuder/java-ordered-properties
+ // instead of java.util.Properties
+ IO.write(props, null, propFile)
+ propFile
+ }
+
+ /** The global versions.properties data */
+ lazy val versionProps: Map[String, String] = {
+ val props = new Properties()
+ val in = new FileInputStream(file("versions.properties"))
+ try props.load(in)
+ finally in.close()
+ props.asScala.toMap.map {
+ case (k, v) => (k, sys.props.getOrElse(k, v)) // allow system properties to override versions.properties
+ }
+ }
+
+ /** Get a subproject version number from `versionProps` */
+ def versionNumber(name: String): String =
+ versionProps(s"$name.version.number")
+}
diff --git a/project/build.properties b/project/build.properties
index 817bc38df8..43b8278c68 100644
--- a/project/build.properties
+++ b/project/build.properties
@@ -1 +1 @@
-sbt.version=0.13.9
+sbt.version=0.13.11
diff --git a/project/plugins.sbt b/project/plugins.sbt
index dc266a8db1..c21824baf9 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -1 +1,5 @@
-libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.3.2" \ No newline at end of file
+libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.3.2"
+
+libraryDependencies += "org.pantsbuild" % "jarjar" % "1.6.0"
+
+libraryDependencies += "biz.aQute" % "bndlib" % "1.50.0"
diff --git a/scripts/common b/scripts/common
index b075469379..bfddf3d149 100644
--- a/scripts/common
+++ b/scripts/common
@@ -18,6 +18,9 @@ IVY_CACHE="$WORKSPACE/.ivy2"
mkdir -p $IVY_CACHE
rm -rf $IVY_CACHE/cache/org.scala-lang
+SBT_CMD=${sbtCmd-sbt}
+SBT_CMD="$SBT_CMD -sbt-version 0.13.11"
+
# temp dir where all 'non-build' operation are performed
TMP_ROOT_DIR=$(mktemp -d -t pr-scala.XXXX)
TMP_DIR="${TMP_ROOT_DIR}/tmp"
diff --git a/scripts/jobs/integrate/bootstrap b/scripts/jobs/integrate/bootstrap
index 8d04e7fc79..a81c672d6e 100755..100644
--- a/scripts/jobs/integrate/bootstrap
+++ b/scripts/jobs/integrate/bootstrap
@@ -22,7 +22,7 @@
# - To prevent staging on sonatype (for testing), set publishToSonatype to anything but "yes"
# - Note: After building a release, the jenkins job provides an updated versions.properties file as artifact.
# Put this file in the Scala repo and create a pull request, and also update the file build.number.
-#
+#
# - Otherwise, a nightly release is built:
# - version number is read from the build.number file, extended with -$sha-nightly
@@ -73,7 +73,7 @@
# Requirements
-# - sbtCmd must point to sbt from sbt-extras
+# - SBT_CMD must point to sbt from sbt-extras
# - ~/.sonatype-curl, ~/.m2/settings.xml, ~/.credentials, ~/.credentials-sonatype, ~/.credentials-private-repo
# as defined by https://github.com/scala/scala-jenkins-infra/tree/master/templates/default
# - ~/.sbt/0.13/plugins/gpg.sbt with:
@@ -89,10 +89,6 @@ publishSonatypeTaskCore=${publishSonatypeTaskCore-"publish-signed"}
publishSonatypeTaskModules=${publishSonatypeTaskModules-"publish-signed"}
publishLockerPrivateTask=${publishLockerPrivateTask-$publishPrivateTask} # set to "init" to speed up testing of the script (if you already built locker before)
-sbtCmd=${sbtCmd-sbt} # TESTING (this is a marker for defaults to change when testing locally: should be sbtx on my mac)
-
-sbtCmd="$sbtCmd -sbt-version 0.13.8"
-
forceRebuild=${forceRebuild-no}
antBuildTask="${antBuildTask-nightly}" # TESTING leave empty to avoid the sanity check (don't set it to "init" because ant will croak)
@@ -180,8 +176,8 @@ function st_stagingRepoClose() {
sbtArgs="-no-colors -ivy $baseDir/ivy2 -Dsbt.override.build.repos=true -Dsbt.repository.config=$sbtRepositoryConfig -Dsbt.global.base=$HOME/.sbt/0.13 -sbt-dir $HOME/.sbt/0.13"
sbtBuild() {
- echo "### sbtBuild: "$sbtCmd $sbtArgs "${scalaVersionTasks[@]}" "${publishTasks[@]}" "$@"
- $sbtCmd $sbtArgs "${scalaVersionTasks[@]}" "${publishTasks[@]}" "$@" >> $baseDir/logs/builds 2>&1
+ echo "### sbtBuild: "$SBT_CMD $sbtArgs "${scalaVersionTasks[@]}" "${publishTasks[@]}" "$@"
+ $SBT_CMD $sbtArgs "${scalaVersionTasks[@]}" "${publishTasks[@]}" "$@" >> $baseDir/logs/builds 2>&1
}
sbtResolve() {
@@ -189,8 +185,8 @@ sbtResolve() {
touch build.sbt
# Can be set to `full` if a module requires cross-versioning against the full Scala version, like the continuations plugin.
cross=${4-binary}
- echo "### sbtResolve: $sbtCmd $sbtArgs " "${scalaVersionTasks[@]}" "\"$1\" % \"$2\" % \"$3\" cross CrossVersion.$cross"
- $sbtCmd $sbtArgs "${scalaVersionTasks[@]}" \
+ echo "### sbtResolve: $SBT_CMD $sbtArgs " "${scalaVersionTasks[@]}" "\"$1\" % \"$2\" % \"$3\" cross CrossVersion.$cross"
+ $SBT_CMD $sbtArgs "${scalaVersionTasks[@]}" \
"set libraryDependencies := Seq(\"$1\" % \"$2\" % \"$3\" cross CrossVersion.$cross)" \
'show update' >> $baseDir/logs/resolution 2>&1
}
@@ -242,22 +238,13 @@ buildPartest() {
fi
}
-# buildPartestIface() {
-# if [ "$forceRebuild" != "yes" ] && ( sbtResolve "org.scala-lang.modules" "scala-partest-interface" $PARTEST_IFACE_VER )
-# then echo "Found scala-partest-interface $PARTEST_IFACE_VER; not building."
-# else
-# update scala scala-partest-interface "$PARTEST_IFACE_REF" && gfxd
-# sbtBuild 'set version :="'$PARTEST_IFACE_VER'"' $clean "${buildTasks[@]}"
-# fi
-# }
-
buildContinuations() {
if [ "$CONT_PLUG_BUILT" != "yes" ] && [ "$forceRebuild" != "yes" ] && ( sbtResolve "org.scala-lang.plugins" "scala-continuations-plugin" $CONTINUATIONS_VER full )
then echo "Found scala-continuations-plugin $CONTINUATIONS_VER; not building."
else
update scala scala-continuations $CONTINUATIONS_REF && gfxd
- $sbtCmd $sbtArgs 'project plugin' "${scalaVersionTasks[@]}" "${publishTasks[@]}" \
+ $SBT_CMD $sbtArgs 'project plugin' "${scalaVersionTasks[@]}" "${publishTasks[@]}" \
'set version := "'$CONTINUATIONS_VER'"' $clean "compile:package" test "${buildTasks[@]}" # https://github.com/scala/scala-continuations/pull/4
CONT_PLUG_BUILT="yes"
fi
@@ -266,7 +253,7 @@ buildContinuations() {
then echo "Found scala-continuations-library $CONTINUATIONS_VER; not building."
else
update scala scala-continuations $CONTINUATIONS_REF && gfxd
- $sbtCmd $sbtArgs 'project library' "${scalaVersionTasks[@]}" "${publishTasks[@]}" \
+ $SBT_CMD $sbtArgs 'project library' "${scalaVersionTasks[@]}" "${publishTasks[@]}" \
'set version := "'$CONTINUATIONS_VER'"' $clean test "${buildTasks[@]}"
CONT_LIB_BUILT="yes"
fi
@@ -316,7 +303,6 @@ buildModules() {
buildActorsMigration
buildScalacheck
buildPartest
- # buildPartestIface
}
buildPublishedModules() {
@@ -328,7 +314,6 @@ buildPublishedModules() {
buildSwing
buildActorsMigration
buildPartest
- # buildPartestIface
}
@@ -445,7 +430,6 @@ deriveModuleVersions() {
SWING_REF="v$SWING_VER"
ACTORS_MIGRATION_REF="v$ACTORS_MIGRATION_VER"
PARTEST_REF="v$PARTEST_VER"
- # PARTEST_IFACE_REF="v$PARTEST_IFACE_VER"
SCALACHECK_REF="$SCALACHECK_VER" # no `v` in their tags
else
# use HEAD as default when no revision is specified on the command line
@@ -455,7 +439,6 @@ deriveModuleVersions() {
SWING_REF=${SWING_REF-"HEAD"}
ACTORS_MIGRATION_REF=${ACTORS_MIGRATION_REF-"HEAD"}
PARTEST_REF=${PARTEST_REF-"HEAD"}
- # PARTEST_IFACE_REF=${PARTEST_IFACE_REF-"HEAD"}
SCALACHECK_REF=${SCALACHECK_REF-"HEAD"}
XML_VER=$(deriveVersion scala scala-xml "$XML_REF")
@@ -476,7 +459,6 @@ deriveModuleVersions() {
echo "SWING = $SWING_VER at $SWING_REF"
echo "XML = $XML_VER at $XML_REF"
- # PARTEST_IFACE_VER=${PARTEST_IFACE_VER-$(deriveVersion scala scala-partest-interface "$PARTEST_IFACE_REF")}
}
createNetrcFile() {
diff --git a/scripts/jobs/integrate/windows b/scripts/jobs/integrate/windows
new file mode 100755
index 0000000000..be68a826f7
--- /dev/null
+++ b/scripts/jobs/integrate/windows
@@ -0,0 +1,15 @@
+#!/bin/bash -x
+
+./pull-binary-libs.sh
+
+export ANT_OPTS="-Dfile.encoding=UTF-8 -server -XX:+AggressiveOpts -XX:+UseParNewGC -Xmx2G -Xss1M -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=128M"
+
+# TODO: don't hardcode this path, which is just where we currently have
+# ant manually installed on jenkins-worker-windows-publish.
+PATH=/cygdrive/c/apache-ant-1.9.6/bin:$PATH
+
+ant \
+ -Dstarr.version=2.11.7 \
+ -Dscalac.args.optimise=-optimise \
+ -Dlocker.skip=1 \
+ test
diff --git a/scripts/jobs/validate/publish-core b/scripts/jobs/validate/publish-core
index 9dff5a34b0..bb0056722d 100755
--- a/scripts/jobs/validate/publish-core
+++ b/scripts/jobs/validate/publish-core
@@ -15,17 +15,8 @@ case $prDryRun in
mkdir -p build/pack ; mkdir -p dists/maven/latest
;;
*)
- sha=$(git rev-parse HEAD) # TODO: warn if $repo_ref != $sha (we shouldn't do PR validation using symbolic gitrefs)
- echo "sha/repo_ref == $sha/$repo_ref ?"
-
- parseScalaProperties build.number
-
- ./pull-binary-libs.sh
- # "noyoudont" is there juuuust in case
- antDeployArgs="-Dmaven.version.suffix=\"-${sha:0:7}-SNAPSHOT\" -Dremote.snapshot.repository=$prRepoUrl -Drepository.credentials.id=pr-scala -Dremote.release.repository=noyoudont"
-
echo ">>> Getting Scala version number."
- ant -q $antDeployArgs init
+ $SBT_CMD "setupPublishCore $prRepoUrl" generateBuildCharacterPropertiesFile
parseScalaProperties buildcharacter.properties # produce maven_version_number
echo ">>> Checking availability of Scala ${maven_version_number} in $prRepoUrl."
@@ -36,7 +27,7 @@ case $prDryRun in
if $libraryAvailable && $reflectAvailable && $compilerAvailable; then
echo "Scala core already built!"
else
- ant $antDeployArgs $antBuildArgs publish-opt-nodocs
+ $SBT_CMD "setupPublishCore $prRepoUrl" $antBuildArgs publish
fi
mv buildcharacter.properties jenkins.properties # parsed by the jenkins job
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/spec/06-expressions.md b/spec/06-expressions.md
index 9cd58ea346..c24ca01c3b 100644
--- a/spec/06-expressions.md
+++ b/spec/06-expressions.md
@@ -1341,7 +1341,7 @@ to $U$ after applying [eta-expansion](#eta-expansion) and
### Value Conversions
-The following five implicit conversions can be applied to an
+The following seven implicit conversions can be applied to an
expression $e$ which has some value type $T$ and which is type-checked with
some expected type $\mathit{pt}$.
diff --git a/spec/07-implicits.md b/spec/07-implicits.md
index 726320ed33..28f6dfe5a8 100644
--- a/spec/07-implicits.md
+++ b/spec/07-implicits.md
@@ -357,8 +357,16 @@ they appear and all the resulting evidence parameters are concatenated
in one implicit parameter section. Since traits do not take
constructor parameters, this translation does not work for them.
Consequently, type-parameters in traits may not be view- or context-bounded.
-Also, a method or class with view- or context bounds may not define any
-additional implicit parameters.
+
+Evidence parameters are prepended to the existing implicit parameter section, if one exists.
+
+For example:
+
+```scala
+def foo[A: M](implicit b: B): C
+// expands to:
+// def foo[A](implicit evidence$1: M[A], b: B): C
+```
###### Example
The `<=` method from the [`Ordered` example](#example-ordered) can be declared
diff --git a/src/build/genprod.scala b/src/build/genprod.scala
index b470348e8c..f85a151ae5 100644
--- a/src/build/genprod.scala
+++ b/src/build/genprod.scala
@@ -15,7 +15,6 @@ import scala.language.postfixOps
* where the argument is the desired output directory
*
* @author Burak Emir, Stephane Micheloud, Geoffrey Washburn, Paul Phillips
- * @version 1.1
*/
object genprod extends App {
val MAX_ARITY = 22
@@ -353,7 +352,7 @@ object ProductTwo extends Product(2)
class Product(val i: Int) extends Group("Product") with Arity {
val productElementComment = """
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/build/maven/scala-actors-pom.xml b/src/build/maven/scala-actors-pom.xml
index a0ebcecad1..37500bf9ae 100644
--- a/src/build/maven/scala-actors-pom.xml
+++ b/src/build/maven/scala-actors-pom.xml
@@ -44,8 +44,8 @@
<name>EPFL LAMP</name>
</developer>
<developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
+ <id>Lightbend</id>
+ <name>Lightbend, Inc.</name>
</developer>
</developers>
</project>
diff --git a/src/build/maven/scala-compiler-doc-pom.xml b/src/build/maven/scala-compiler-doc-pom.xml
index 8572e55b42..0c33d23d61 100644
--- a/src/build/maven/scala-compiler-doc-pom.xml
+++ b/src/build/maven/scala-compiler-doc-pom.xml
@@ -51,8 +51,8 @@
<name>EPFL LAMP</name>
</developer>
<developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
+ <id>Lightbend</id>
+ <name>Lightbend, Inc.</name>
</developer>
</developers>
</project>
diff --git a/src/build/maven/scala-compiler-interactive-pom.xml b/src/build/maven/scala-compiler-interactive-pom.xml
index ad8192b694..d3e5e0b834 100644
--- a/src/build/maven/scala-compiler-interactive-pom.xml
+++ b/src/build/maven/scala-compiler-interactive-pom.xml
@@ -41,8 +41,8 @@
<name>EPFL LAMP</name>
</developer>
<developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
+ <id>Lightbend</id>
+ <name>Lightbend, Inc.</name>
</developer>
</developers>
</project>
diff --git a/src/build/maven/scala-compiler-pom.xml b/src/build/maven/scala-compiler-pom.xml
index 8ca18f6f14..15546109c8 100644
--- a/src/build/maven/scala-compiler-pom.xml
+++ b/src/build/maven/scala-compiler-pom.xml
@@ -63,8 +63,8 @@
<name>EPFL LAMP</name>
</developer>
<developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
+ <id>Lightbend</id>
+ <name>Lightbend, Inc.</name>
</developer>
</developers>
</project>
diff --git a/src/build/maven/scala-dist-pom.xml b/src/build/maven/scala-dist-pom.xml
index 9477e14285..6788ff0106 100644
--- a/src/build/maven/scala-dist-pom.xml
+++ b/src/build/maven/scala-dist-pom.xml
@@ -68,8 +68,8 @@
<name>EPFL LAMP</name>
</developer>
<developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
+ <id>Lightbend</id>
+ <name>Lightbend, Inc.</name>
</developer>
</developers>
</project>
diff --git a/src/build/maven/scala-library-all-pom.xml b/src/build/maven/scala-library-all-pom.xml
index 3fcf207559..1991bae131 100644
--- a/src/build/maven/scala-library-all-pom.xml
+++ b/src/build/maven/scala-library-all-pom.xml
@@ -81,8 +81,8 @@
<name>EPFL LAMP</name>
</developer>
<developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
+ <id>Lightbend</id>
+ <name>Lightbend, Inc.</name>
</developer>
</developers>
</project>
diff --git a/src/build/maven/scala-library-pom.xml b/src/build/maven/scala-library-pom.xml
index 78fc05a7c3..e27f8fb12f 100644
--- a/src/build/maven/scala-library-pom.xml
+++ b/src/build/maven/scala-library-pom.xml
@@ -39,8 +39,8 @@
<name>EPFL LAMP</name>
</developer>
<developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
+ <id>Lightbend</id>
+ <name>Lightbend, Inc.</name>
</developer>
</developers>
</project>
diff --git a/src/build/maven/scala-reflect-pom.xml b/src/build/maven/scala-reflect-pom.xml
index c21caefcf2..f7f3c8bc08 100644
--- a/src/build/maven/scala-reflect-pom.xml
+++ b/src/build/maven/scala-reflect-pom.xml
@@ -44,8 +44,8 @@
<name>EPFL LAMP</name>
</developer>
<developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
+ <id>Lightbend</id>
+ <name>Lightbend, Inc.</name>
</developer>
</developers>
</project>
diff --git a/src/build/maven/scalap-pom.xml b/src/build/maven/scalap-pom.xml
index 236ac999fc..acdd44f19b 100644
--- a/src/build/maven/scalap-pom.xml
+++ b/src/build/maven/scalap-pom.xml
@@ -41,8 +41,8 @@
<name>EPFL LAMP</name>
</developer>
<developer>
- <id>Typesafe</id>
- <name>Typesafe, Inc.</name>
+ <id>Lightbend</id>
+ <name>Lightbend, Inc.</name>
</developer>
</developers>
</project>
diff --git a/src/compiler/scala/reflect/quasiquotes/Parsers.scala b/src/compiler/scala/reflect/quasiquotes/Parsers.scala
index 97ec7dbfc3..108ad0bc2e 100644
--- a/src/compiler/scala/reflect/quasiquotes/Parsers.scala
+++ b/src/compiler/scala/reflect/quasiquotes/Parsers.scala
@@ -59,6 +59,10 @@ trait Parsers { self: Quasiquotes =>
override implicit lazy val fresh: FreshNameCreator = new FreshNameCreator(nme.QUASIQUOTE_PREFIX)
+ // Do not check for tuple arity. The placeholders can support arbitrary tuple sizes.
+ override def makeSafeTupleTerm(trees: List[Tree], offset: Offset): Tree = treeBuilder.makeTupleTerm(trees)
+ override def makeSafeTupleType(trees: List[Tree], offset: Offset): Tree = treeBuilder.makeTupleType(trees)
+
override val treeBuilder = new ParserTreeBuilder {
override implicit def fresh: FreshNameCreator = parser.fresh
diff --git a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala
index 2584054686..24496fa013 100644
--- a/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala
+++ b/src/compiler/scala/tools/nsc/GenericRunnerCommand.scala
@@ -87,7 +87,11 @@ A file argument will be run as a scala script unless it contains only
self-contained compilation units (classes and objects) and exactly one
runnable main method. In that case the file will be compiled and the
main method invoked. This provides a bridge between scripts and standard
-scala source.%n"""
+scala source.
+
+When running a script or using -e, an already running compilation daemon
+(fsc) is used, or a new one started on demand. The -nc option can be
+used to prevent this.%n"""
}
object GenericRunnerCommand {
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/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 4494a8ac8d..c04d305f9e 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -766,7 +766,58 @@ self =>
@inline final def caseSeparated[T](part: => T): List[T] = tokenSeparated(CASE, sepFirst = true, part)
def readAnnots(part: => Tree): List[Tree] = tokenSeparated(AT, sepFirst = true, part)
-/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
+ /** Create a tuple type Tree. If the arity is not supported, a syntax error is emitted. */
+ def makeSafeTupleType(elems: List[Tree], offset: Offset) = {
+ if (checkTupleSize(elems, offset)) makeTupleType(elems)
+ else makeTupleType(Nil) // create a dummy node; makeTupleType(elems) would fail
+ }
+
+ /** Create a tuple term Tree. If the arity is not supported, a syntax error is emitted. */
+ def makeSafeTupleTerm(elems: List[Tree], offset: Offset) = {
+ checkTupleSize(elems, offset)
+ makeTupleTerm(elems)
+ }
+
+ private[this] def checkTupleSize(elems: List[Tree], offset: Offset): Boolean =
+ if (elems.lengthCompare(definitions.MaxTupleArity) > 0) {
+ syntaxError(offset, "too many elements for tuple: "+elems.length+", allowed: "+definitions.MaxTupleArity, skipIt = false)
+ false
+ } else true
+
+ /** Strip the artifitial `Parens` node to create a tuple term Tree. */
+ def stripParens(t: Tree) = t match {
+ case Parens(ts) => atPos(t.pos) { makeSafeTupleTerm(ts, t.pos.point) }
+ case _ => t
+ }
+
+ /** Create tree representing (unencoded) binary operation expression or pattern. */
+ def makeBinop(isExpr: Boolean, left: Tree, op: TermName, right: Tree, opPos: Position, targs: List[Tree] = Nil): Tree = {
+ require(isExpr || targs.isEmpty || targs.exists(_.isErroneous), s"Incompatible args to makeBinop: !isExpr but targs=$targs")
+
+ def mkSelection(t: Tree) = {
+ def sel = atPos(opPos union t.pos)(Select(stripParens(t), op.encode))
+ if (targs.isEmpty) sel else atPos(left.pos)(TypeApply(sel, targs))
+ }
+ def mkNamed(args: List[Tree]) = if (isExpr) args map treeInfo.assignmentToMaybeNamedArg else args
+ val arguments = right match {
+ case Parens(args) => mkNamed(args)
+ case _ => List(right)
+ }
+ if (isExpr) {
+ if (treeInfo.isLeftAssoc(op)) {
+ Apply(mkSelection(left), arguments)
+ } else {
+ val x = freshTermName()
+ Block(
+ List(ValDef(Modifiers(symtab.Flags.SYNTHETIC | symtab.Flags.ARTIFACT), x, TypeTree(), stripParens(left))),
+ Apply(mkSelection(right), List(Ident(x))))
+ }
+ } else {
+ Apply(Ident(op.encode), stripParens(left) :: arguments)
+ }
+ }
+
+ /* --------- OPERAND/OPERATOR STACK --------------------------------------- */
/** Modes for infix types. */
object InfixMode extends Enumeration {
@@ -870,7 +921,7 @@ self =>
atPos(start, in.skipToken()) { makeFunctionTypeTree(ts, typ()) }
else {
ts foreach checkNotByNameOrVarargs
- val tuple = atPos(start) { makeTupleType(ts) }
+ val tuple = atPos(start) { makeSafeTupleType(ts, start) }
infixTypeRest(
compoundTypeRest(
annotTypeRest(
@@ -937,7 +988,7 @@ self =>
def simpleType(): Tree = {
val start = in.offset
simpleTypeRest(in.token match {
- case LPAREN => atPos(start)(makeTupleType(inParens(types())))
+ case LPAREN => atPos(start)(makeSafeTupleType(inParens(types()), start))
case USCORE => wildcardType(in.skipToken())
case _ =>
path(thisOK = false, typeOK = true) match {
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index 6e5a3f6ef7..cc9e39f430 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -43,44 +43,12 @@ abstract class TreeBuilder {
def makeTupleType(elems: List[Tree]) = gen.mkTupleType(elems)
- def stripParens(t: Tree) = t match {
- case Parens(ts) => atPos(t.pos) { makeTupleTerm(ts) }
- case _ => t
- }
-
def makeAnnotated(t: Tree, annot: Tree): Tree =
atPos(annot.pos union t.pos)(Annotated(annot, t))
def makeSelfDef(name: TermName, tpt: Tree): ValDef =
ValDef(Modifiers(PRIVATE), name, tpt, EmptyTree)
- /** Create tree representing (unencoded) binary operation expression or pattern. */
- def makeBinop(isExpr: Boolean, left: Tree, op: TermName, right: Tree, opPos: Position, targs: List[Tree] = Nil): Tree = {
- require(isExpr || targs.isEmpty || targs.exists(_.isErroneous), s"Incompatible args to makeBinop: !isExpr but targs=$targs")
-
- def mkSelection(t: Tree) = {
- def sel = atPos(opPos union t.pos)(Select(stripParens(t), op.encode))
- if (targs.isEmpty) sel else atPos(left.pos)(TypeApply(sel, targs))
- }
- def mkNamed(args: List[Tree]) = if (isExpr) args map treeInfo.assignmentToMaybeNamedArg else args
- val arguments = right match {
- case Parens(args) => mkNamed(args)
- case _ => List(right)
- }
- if (isExpr) {
- if (treeInfo.isLeftAssoc(op)) {
- Apply(mkSelection(left), arguments)
- } else {
- val x = freshTermName()
- Block(
- List(ValDef(Modifiers(SYNTHETIC | ARTIFACT), x, TypeTree(), stripParens(left))),
- Apply(mkSelection(right), List(Ident(x))))
- }
- } else {
- Apply(Ident(op.encode), stripParens(left) :: arguments)
- }
- }
-
/** Tree for `od op`, start is start0 if od.pos is borked. */
def makePostfixSelect(start0: Int, end: Int, od: Tree, op: Name): Tree = {
val start = if (od.pos.isDefined) od.pos.start else start0
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/backend/jvm/opt/BytecodeUtils.scala b/src/compiler/scala/tools/nsc/backend/jvm/opt/BytecodeUtils.scala
index df8dcc690a..7aadd2c466 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/opt/BytecodeUtils.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/opt/BytecodeUtils.scala
@@ -114,7 +114,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/backend/opt/ConstantOptimization.scala b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
index fb1799e092..a7ce7dfa04 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala
@@ -248,7 +248,7 @@ abstract class ConstantOptimization extends SubComponent {
new State(newVariables, stack.tail)
}
/**
- * Load the specified local onto the top of the stack. An error the the local is uninitialized.
+ * Load the specified local onto the top of the stack. An error if the local is uninitialized.
*/
def load(variable: Local): State = {
val contents: Contents = locals.getOrElse(variable, sys.error(s"$variable is not initialized"))
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/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala
index 6a46c65267..b2aac587eb 100644
--- a/src/compiler/scala/tools/nsc/transform/Constructors.scala
+++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala
@@ -328,7 +328,7 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL {
val delayedHook: DefDef = delayedEndpointDef(remainingConstrStats)
defBuf += delayedHook
val hookCallerClass = {
- // transform to make the closure-class' default constructor assign the the outer instance to its param-accessor field.
+ // transform to make the closure-class' default constructor assign the outer instance to its param-accessor field.
val drillDown = new ConstructorTransformer(unit)
drillDown transform delayedInitClosure(delayedHook.symbol.asInstanceOf[MethodSymbol])
}
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/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index ee7c839de9..870c35338c 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -638,7 +638,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 62d9c497ba..91777b34d5 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 451b72d498..a2afb76b0e 100644
--- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
+++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
@@ -504,14 +504,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/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index b0bd9977a8..727f09290a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -1190,7 +1190,7 @@ trait ContextErrors {
def IllegalDependentMethTpeError(sym: Symbol)(context: Context) = {
val errorAddendum =
- ": parameter appears in the type of another parameter in the same section or an earlier one"
+ ": parameter may only be referenced in a subsequent parameter section"
issueSymbolTypeError(sym, "illegal dependent method type" + errorAddendum)(context)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index e73a4c6276..5ec16e84bb 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -806,6 +806,12 @@ trait Contexts { self: Analyzer =>
(e ne null) && (e.owner == scope) && (!settings.isScala212 || e.sym.exists)
})
+ private def withQualifyingImplicitAlternatives(imp: ImportInfo, name: Name, pre: Type)(f: Symbol => Unit) =
+ for {
+ sym <- importedAccessibleSymbol(imp, name, requireExplicit = false, record = false).alternatives
+ if isQualifyingImplicit(name, sym, pre, imported = true)
+ } f(sym)
+
private def collectImplicits(syms: Scope, pre: Type, imported: Boolean = false): List[ImplicitInfo] =
for (sym <- syms.toList if isQualifyingImplicit(sym.name, sym, pre, imported)) yield
new ImplicitInfo(sym.name, pre, sym)
@@ -815,7 +821,7 @@ trait Contexts { self: Analyzer =>
val pre =
if (qual.tpe.typeSymbol.isPackageClass)
- // SI-6225 important if the imported symbol is inherited by the the package object.
+ // SI-6225 important if the imported symbol is inherited by the package object.
singleType(qual.tpe, qual.tpe member nme.PACKAGE)
else
qual.tpe
@@ -832,9 +838,9 @@ trait Contexts { self: Analyzer =>
case ImportSelector(from, _, to, _) :: sels1 =>
var impls = collect(sels1) filter (info => info.name != from)
if (to != nme.WILDCARD) {
- for (sym <- importedAccessibleSymbol(imp, to).alternatives)
- if (isQualifyingImplicit(to, sym, pre, imported = true))
- impls = new ImplicitInfo(to, pre, sym) :: impls
+ withQualifyingImplicitAlternatives(imp, to, pre) { sym =>
+ impls = new ImplicitInfo(to, pre, sym) :: impls
+ }
}
impls
}
@@ -958,11 +964,8 @@ trait Contexts { self: Analyzer =>
/** The symbol with name `name` imported via the import in `imp`,
* if any such symbol is accessible from this context.
*/
- def importedAccessibleSymbol(imp: ImportInfo, name: Name): Symbol =
- importedAccessibleSymbol(imp, name, requireExplicit = false)
-
- private def importedAccessibleSymbol(imp: ImportInfo, name: Name, requireExplicit: Boolean): Symbol =
- imp.importedSymbol(name, requireExplicit) filter (s => isAccessible(s, imp.qual.tpe, superAccess = false))
+ private def importedAccessibleSymbol(imp: ImportInfo, name: Name, requireExplicit: Boolean, record: Boolean): Symbol =
+ imp.importedSymbol(name, requireExplicit, record) filter (s => isAccessible(s, imp.qual.tpe, superAccess = false))
/** Is `sym` defined in package object of package `pkg`?
* Since sym may be defined in some parent of the package object,
@@ -1108,7 +1111,7 @@ trait Contexts { self: Analyzer =>
def imp2Explicit = imp2 isExplicitImport name
def lookupImport(imp: ImportInfo, requireExplicit: Boolean) =
- importedAccessibleSymbol(imp, name, requireExplicit) filter qualifies
+ importedAccessibleSymbol(imp, name, requireExplicit, record = true) filter qualifies
// Java: A single-type-import declaration d in a compilation unit c of package p
// that imports a type named n shadows, throughout c, the declarations of:
@@ -1422,7 +1425,7 @@ trait Contexts { self: Analyzer =>
/** The symbol with name `name` imported from import clause `tree`.
*/
- def importedSymbol(name: Name): Symbol = importedSymbol(name, requireExplicit = false)
+ def importedSymbol(name: Name): Symbol = importedSymbol(name, requireExplicit = false, record = true)
private def recordUsage(sel: ImportSelector, result: Symbol) {
def posstr = pos.source.file.name + ":" + posOf(sel).line
@@ -1432,7 +1435,7 @@ trait Contexts { self: Analyzer =>
}
/** If requireExplicit is true, wildcard imports are not considered. */
- def importedSymbol(name: Name, requireExplicit: Boolean): Symbol = {
+ def importedSymbol(name: Name, requireExplicit: Boolean, record: Boolean): Symbol = {
var result: Symbol = NoSymbol
var renamed = false
var selectors = tree.selectors
@@ -1449,7 +1452,7 @@ trait Contexts { self: Analyzer =>
if (result == NoSymbol)
selectors = selectors.tail
}
- if (settings.warnUnusedImport && selectors.nonEmpty && result != NoSymbol && pos != NoPosition)
+ if (record && settings.warnUnusedImport && selectors.nonEmpty && result != NoSymbol && pos != NoPosition)
recordUsage(current, result)
// Harden against the fallout from bugs like SI-6745
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/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/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index c5abd756f8..3b2e07bdbd 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1503,9 +1503,8 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
}
}
- private def transformCaseApply(tree: Tree, ifNot: => Unit) = {
+ private def isSimpleCaseApply(tree: Tree): Boolean = {
val sym = tree.symbol
-
def isClassTypeAccessible(tree: Tree): Boolean = tree match {
case TypeApply(fun, targs) =>
isClassTypeAccessible(fun)
@@ -1513,31 +1512,26 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
( // SI-4859 `CaseClass1().InnerCaseClass2()` must not be rewritten to `new InnerCaseClass2()`;
// {expr; Outer}.Inner() must not be rewritten to `new Outer.Inner()`.
treeInfo.isQualifierSafeToElide(module) &&
- // SI-5626 Classes in refinement types cannot be constructed with `new`. In this case,
- // the companion class is actually not a ClassSymbol, but a reference to an abstract type.
- module.symbol.companionClass.isClass
- )
+ // SI-5626 Classes in refinement types cannot be constructed with `new`. In this case,
+ // the companion class is actually not a ClassSymbol, but a reference to an abstract type.
+ module.symbol.companionClass.isClass
+ )
}
- val doTransform =
- sym.isSourceMethod &&
+ sym.isSourceMethod &&
sym.isCase &&
sym.name == nme.apply &&
isClassTypeAccessible(tree) &&
- !tree.tpe.resultType.typeSymbol.primaryConstructor.isLessAccessibleThan(tree.symbol)
+ !tree.tpe.finalResultType.typeSymbol.primaryConstructor.isLessAccessibleThan(tree.symbol)
+ }
- if (doTransform) {
- tree foreach {
- case i@Ident(_) =>
- enterReference(i.pos, i.symbol) // SI-5390 need to `enterReference` for `a` in `a.B()`
- case _ =>
- }
- toConstructor(tree.pos, tree.tpe)
- }
- else {
- ifNot
- tree
+ private def transformCaseApply(tree: Tree) = {
+ tree foreach {
+ case i@Ident(_) =>
+ enterReference(i.pos, i.symbol) // SI-5390 need to `enterReference` for `a` in `a.B()`
+ case _ =>
}
+ toConstructor(tree.pos, tree.tpe)
}
private def transformApply(tree: Apply): Tree = tree match {
@@ -1577,12 +1571,24 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
// term should have been eliminated by super accessors
assert(!(qual.symbol.isTrait && sym.isTerm && mix == tpnme.EMPTY), (qual.symbol, sym, mix))
- transformCaseApply(tree,
+ // Rewrite eligible calls to monomorphic case companion apply methods to the equivalent constructor call.
+ //
+ // Note: for generic case classes the rewrite needs to be handled at the enclosing `TypeApply` to transform
+ // `TypeApply(Select(C, apply), targs)` to `Select(New(C[targs]), <init>)`. In case such a `TypeApply`
+ // was deemed ineligible for transformation (e.g. the case constructor was private), the refchecks transform
+ // will recurse to this point with `Select(C, apply)`, which will have a type `[T](...)C[T]`.
+ //
+ // We don't need to perform the check on the Select node, and `!isHigherKinded will guard against this
+ // redundant (and previously buggy, SI-9546) consideration.
+ if (!tree.tpe.isHigherKinded && isSimpleCaseApply(tree)) {
+ transformCaseApply(tree)
+ } else {
qual match {
case Super(_, mix) => checkSuper(mix)
case _ =>
}
- )
+ tree
+ }
}
private def transformIf(tree: If): Tree = {
val If(cond, thenpart, elsepart) = tree
@@ -1706,7 +1712,10 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
case TypeApply(fn, args) =>
checkBounds(tree, NoPrefix, NoSymbol, fn.tpe.typeParams, args map (_.tpe))
- transformCaseApply(tree, ())
+ if (isSimpleCaseApply(tree))
+ transformCaseApply(tree)
+ else
+ tree
case x @ Apply(_, _) =>
transformApply(x)
@@ -1725,12 +1734,11 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
case Ident(name) =>
checkUndesiredProperties(sym, tree.pos)
- transformCaseApply(tree,
- if (name != nme.WILDCARD && name != tpnme.WILDCARD_STAR) {
- assert(sym != NoSymbol, "transformCaseApply: name = " + name.debugString + " tree = " + tree + " / " + tree.getClass) //debug
- enterReference(tree.pos, sym)
- }
- )
+ if (name != nme.WILDCARD && name != tpnme.WILDCARD_STAR) {
+ assert(sym != NoSymbol, "transformCaseApply: name = " + name.debugString + " tree = " + tree + " / " + tree.getClass) //debug
+ enterReference(tree.pos, sym)
+ }
+ tree
case x @ Select(_, _) =>
transformSelect(x)
diff --git a/src/eclipse/README.md b/src/eclipse/README.md
index 03c7403b04..fe2c109402 100644
--- a/src/eclipse/README.md
+++ b/src/eclipse/README.md
@@ -1,13 +1,18 @@
Eclipse project files
=====================
-The following points describe how to get Scala to run in Eclipse. Please also take a look at the [excellent tutorial on scala-ide.org](http://scala-ide.org/docs/tutorials/scalac-trunk/index.html).
+For important details on building, debugging and file encodings, please see [the excellent tutorial on scala-ide.org](http://scala-ide.org/docs/tutorials/scalac-trunk/index.html).
-0. Import all projects into a [very recent version of Scala IDE for Eclipse](http://scala-ide.org/download/nightly.html) by choosing `File/Import Existing Projects`
-and navigate to `scala/src/eclipse`. Check all projects and click ok.
+The following points describe how to build Scala using Eclipse.
-0. You need to define a `path variable` inside Eclipse. Define `SCALA_BASEDIR` in
-`Preferences/General/Workspace/Linked Resources`. The value should be the absolute
+0. Download the [Scala IDE bundle](http://scala-ide.org/download/sdk.html). It comes preconfigured for optimal performance.
+
+0. Run `ant init` to download some necessary jars.
+
+0. Import the project (in `src/eclipse`) via `File` → `Import Existing Projects` and navigate to `scala/src/eclipse`. Check all projects and click ok.
+
+0. You need to define a `path variable` inside Eclipse. Define `SCALA_BASEDIR` in
+`Preferences/General/Workspace/Linked Resources`. The value should be the absolute
path to your Scala checkout. All paths in the project files are relative to this one,
so nothing will work before you do so.
@@ -29,7 +34,7 @@ JDK. The Scala library uses such APIs, so you'd see this error:
Access restriction: The method compareAndSwapObject(Object, long, Object, Object)
from the type Unsafe is not accessible due to restriction on required library.
- You can *fix* it by allowing calls to restricted APIs in `Java/Compiler/Errors/Warnings/Deprecated and Restricted API`
+ You can *fix* it by allowing calls to restricted APIs in `Java/Compiler/Errors/Warnings/Deprecated and Restricted API`
settings.
0. Project files are tracked by Git, so adding them to `.gitignore` won't prevent them
diff --git a/src/eclipse/asm/.classpath b/src/eclipse/asm/.classpath
deleted file mode 100644
index 03d9e9788d..0000000000
--- a/src/eclipse/asm/.classpath
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="asm-quick-bin"/>
-</classpath>
diff --git a/src/eclipse/asm/.project b/src/eclipse/asm/.project
deleted file mode 100644
index c9051389af..0000000000
--- a/src/eclipse/asm/.project
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>asm</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
- <linkedResources>
- <link>
- <name>src</name>
- <type>2</type>
- <locationURI>SCALA_BASEDIR/src/asm</locationURI>
- </link>
- <link>
- <name>asm-quick-bin</name>
- <type>2</type>
- <locationURI>SCALA_BASEDIR/build/asm/classes</locationURI>
- </link>
- </linkedResources>
-</projectDescription>
diff --git a/src/eclipse/interactive/.classpath b/src/eclipse/interactive/.classpath
index 9e773a39d2..565492bc63 100644
--- a/src/eclipse/interactive/.classpath
+++ b/src/eclipse/interactive/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="interactive"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-asm/5.0.4-scala-3/scala-asm-5.0.4-scala-3.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/scaladoc"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
diff --git a/src/eclipse/interactive/.gitignore b/src/eclipse/interactive/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/interactive/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/partest/.classpath b/src/eclipse/partest/.classpath
index 65848ea439..9e3a3c9b6c 100644
--- a/src/eclipse/partest/.classpath
+++ b/src/eclipse/partest/.classpath
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="partest-extras"/>
- <classpathentry combineaccessrules="false" kind="src" path="/asm"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-asm/5.0.4-scala-3/scala-asm-5.0.4-scala-3.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/repl"/>
<classpathentry kind="var" path="M2_REPO/com/googlecode/java-diff-utils/diffutils/1.3.0/diffutils-1.3.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/scala-sbt/test-interface/1.0/test-interface-1.0.jar"/>
diff --git a/src/eclipse/partest/.gitignore b/src/eclipse/partest/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/partest/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/reflect/.gitignore b/src/eclipse/reflect/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/reflect/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/repl/.classpath b/src/eclipse/repl/.classpath
index 14f7e16670..56d83c0f04 100644
--- a/src/eclipse/repl/.classpath
+++ b/src/eclipse/repl/.classpath
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="repl"/>
- <classpathentry combineaccessrules="false" kind="src" path="/asm"/>
- <classpathentry kind="var" path="M2_REPO/jline/jline/2.12.1/jline-2.12.1.jar"/>
- <!-- <classpathentry kind="var" path="SCALA_BASEDIR/build/deps/repl/jline-2.12.jar"/> -->
- <classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
- <classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="build-quick-repl"/>
+ <classpathentry kind="src" path="repl"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-asm/5.0.4-scala-3/scala-asm-5.0.4-scala-3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jline/jline/2.12.1/jline-2.12.1.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/interactive"/>
+ <classpathentry kind="output" path="build-quick-repl"/>
</classpath>
diff --git a/src/eclipse/repl/.gitignore b/src/eclipse/repl/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/repl/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scala-compiler/.classpath b/src/eclipse/scala-compiler/.classpath
index e81cacca26..6c9be61039 100644
--- a/src/eclipse/scala-compiler/.classpath
+++ b/src/eclipse/scala-compiler/.classpath
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="compiler"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/asm"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/reflect"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scala-library"/>
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-asm/5.0.4-scala-3/scala-asm-5.0.4-scala-3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build-quick-compiler"/>
</classpath>
diff --git a/src/eclipse/scala-compiler/.gitignore b/src/eclipse/scala-compiler/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scala-compiler/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scala-library/.gitignore b/src/eclipse/scala-library/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scala-library/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scaladoc/.classpath b/src/eclipse/scaladoc/.classpath
index 3db64f5b0d..568cf678c6 100644
--- a/src/eclipse/scaladoc/.classpath
+++ b/src/eclipse/scaladoc/.classpath
@@ -2,10 +2,10 @@
<classpath>
<classpathentry kind="src" path="scaladoc"/>
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-asm/5.0.4-scala-3/scala-asm-5.0.4-scala-3.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
- <classpathentry combineaccessrules="false" kind="src" path="/partest-extras"/>
<classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-xml_2.11/1.0.4/scala-xml_2.11-1.0.4.jar"/>
<classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-parser-combinators_2.11/1.0.4/scala-parser-combinators_2.11-1.0.4.jar"/>
<classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-partest_2.11/1.0.9/scala-partest_2.11-1.0.9.jar"/>
diff --git a/src/eclipse/scaladoc/.gitignore b/src/eclipse/scaladoc/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scaladoc/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/scalap/.gitignore b/src/eclipse/scalap/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/scalap/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/eclipse/test-junit/.classpath b/src/eclipse/test-junit/.classpath
index 710d33b030..92c0b74f70 100644
--- a/src/eclipse/test-junit/.classpath
+++ b/src/eclipse/test-junit/.classpath
@@ -1,12 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="test-junit"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-asm/5.0.4-scala-3/scala-asm-5.0.4-scala-3.jar"/>
<classpathentry kind="var" path="SCALA_BASEDIR/lib/ant/ant.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/reflect"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-library"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/scala-compiler"/>
<classpathentry combineaccessrules="false" kind="src" path="/repl"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/partest-extras"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/scaladoc"/>
+ <classpathentry kind="var" path="M2_REPO/org/scala-lang/modules/scala-xml_2.11/1.0.4/scala-xml_2.11-1.0.4.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="build-test-junit"/>
</classpath>
diff --git a/src/eclipse/test-junit/.gitignore b/src/eclipse/test-junit/.gitignore
new file mode 100644
index 0000000000..fe789dd686
--- /dev/null
+++ b/src/eclipse/test-junit/.gitignore
@@ -0,0 +1,2 @@
+# what appears to be a Scala IDE-generated file
+.cache-main
diff --git a/src/intellij/README b/src/intellij/README
deleted file mode 100644
index 4ecab5561f..0000000000
--- a/src/intellij/README
+++ /dev/null
@@ -1,12 +0,0 @@
-Use the latest IntelliJ IDEA release and install the Scala plugin from within the IDE.
-
-Compilation withing IDEA is performed in "-Dlocker.skip=1" mode: the sources are built
-directly using the STARR compiler.
-
-The following steps are required to use IntelliJ IDEA on Scala trunk
- - Run "ant init". This will download some JARs from to ./build/deps, which are
- included in IntelliJ's classpath.
- - Run src/intellij/setup.sh
- - Open ./src/intellij/scala.ipr in IntelliJ
- - File, Project Settings, Project, SDK. Create an SDK entry named "1.6" containing the
- Java 1.6 SDK
diff --git a/src/intellij/README.md b/src/intellij/README.md
new file mode 100644
index 0000000000..64e7b8188a
--- /dev/null
+++ b/src/intellij/README.md
@@ -0,0 +1,13 @@
+Use the latest IntelliJ IDEA release and install the Scala plugin from within the IDE.
+
+Compilation withing IDEA is performed in "-Dlocker.skip=1" mode: the sources are built
+directly using the STARR compiler.
+
+The following steps are required to use IntelliJ IDEA on Scala trunk
+ - Run `ant init`. This will download some JARs to `./build/deps`, which are included in IntelliJ's classpath.
+ - Run `./src/intellij/setup.sh`.
+ - Open `./src/intellij/scala.ipr` in IntelliJ.
+ - `File` → `Project Structure` → `Project` → `Project SDK`. Create an SDK entry named "1.6" containing the Java 1.6 SDK. (Or other SDK version; see "Requirements" in the repo's main README.)
+
+Compilation within IDEA is performed in `-Dlocker.skip=1` mode: the sources are built
+directly using the STARR compiler (which is downloaded from [the Central Repository](http://central.sonatype.org/), according to `starr.version` in `versions.properties`).
diff --git a/src/intellij/scala-build.iml.SAMPLE b/src/intellij/scala-build.iml.SAMPLE
new file mode 100644
index 0000000000..0232e9e576
--- /dev/null
+++ b/src/intellij/scala-build.iml.SAMPLE
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.id="scalaz-build" external.linked.project.path="$MODULE_DIR$/../../project" external.root.project.path="$MODULE_DIR$/../.." external.system.id="SBT" sbt.imports="sbt._, Keys._, dsl._, _root_.com.typesafe.sbt.SbtPgp.autoImport._, _root_.sbt.plugins.IvyPlugin, _root_.sbt.plugins.JvmPlugin, _root_.sbt.plugins.CorePlugin, _root_.sbt.plugins.JUnitXmlReportPlugin, _root_.com.typesafe.sbt.SbtPgp" sbt.resolvers="https://repo1.maven.org/maven2/|maven|public, /Users/jason/.ivy2/cache|ivy|Local cache" type="SBT_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/../../project/target/idea-classes" />
+ <output-test url="file://$MODULE_DIR$/../../project/target/idea-test-classes" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/../../project">
+ <sourceFolder url="file://$MODULE_DIR$/../../project" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/../../project/project/target" />
+ <excludeFolder url="file://$MODULE_DIR$/../../project/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library">
+ <library name="SBT: sbt-and-plugins">
+ <CLASSES>
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.apache.commons/commons-lang3/jars/commons-lang3-3.3.2.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.pantsbuild/jarjar/jars/jarjar-1.6.0.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.apache.ant/ant/jars/ant-1.9.6.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.apache.ant/ant-launcher/jars/ant-launcher-1.9.6.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.ow2.asm/asm/jars/asm-5.0.4.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.ow2.asm/asm-commons/jars/asm-commons-5.0.4.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.ow2.asm/asm-tree/jars/asm-tree-5.0.4.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.apache.maven/maven-plugin-api/jars/maven-plugin-api-3.3.3.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.apache.maven/maven-model/jars/maven-model-3.3.3.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.codehaus.plexus/plexus-utils/jars/plexus-utils-3.0.20.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.apache.maven/maven-artifact/jars/maven-artifact-3.3.3.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.eclipse.sisu/org.eclipse.sisu.plexus/eclipse-plugins/org.eclipse.sisu.plexus-0.3.0.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/javax.enterprise/cdi-api/jars/cdi-api-1.0.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/javax.annotation/jsr250-api/jars/jsr250-api-1.0.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/javax.inject/javax.inject/jars/javax.inject-1.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.eclipse.sisu/org.eclipse.sisu.inject/eclipse-plugins/org.eclipse.sisu.inject-0.3.0.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.codehaus.plexus/plexus-component-annotations/jars/plexus-component-annotations-1.5.5.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.codehaus.plexus/plexus-classworlds/bundles/plexus-classworlds-2.5.2.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/biz.aQute.bnd/biz.aQute.bnd/jars/biz.aQute.bnd-2.4.1.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.10.5/lib/scala-library.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/sbt/jars/sbt-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/main/jars/main-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/actions/jars/actions-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/classpath/jars/classpath-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.10.5/lib/scala-compiler.jar!/" />
+ <root url="jar://$USER_HOME$/.sbt/boot/scala-2.10.5/lib/scala-reflect.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/interface/jars/interface-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/io/jars/io-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/control/jars/control-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/launcher-interface/jars/launcher-interface-1.0.0-M1.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/completion/jars/completion-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/collections/jars/collections-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/jline/jline/jars/jline-2.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/api/jars/api-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/compiler-integration/jars/compiler-integration-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/incremental-compiler/jars/incremental-compiler-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/logging/jars/logging-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/process/jars/process-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/relation/jars/relation-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/compile/jars/compile-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/classfile/jars/classfile-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/persist/jars/persist-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-tools.sbinary/sbinary_2.10/jars/sbinary_2.10-0.4.2.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/compiler-ivy-integration/jars/compiler-ivy-integration-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/ivy/jars/ivy-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/cross/jars/cross-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt.ivy/ivy/jars/ivy-2.3.0-sbt-c5d1b95fdcc1e1007740ffbecf4eb07abc51ec93.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/com.jcraft/jsch/jars/jsch-0.1.46.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/serialization_2.10/jars/serialization_2.10-0.1.1.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-lang.modules/scala-pickling_2.10/jars/scala-pickling_2.10-0.10.0.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scalamacros/quasiquotes_2.10/jars/quasiquotes_2.10-2.0.1.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.json4s/json4s-core_2.10/jars/json4s-core_2.10-3.2.10.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.json4s/json4s-ast_2.10/jars/json4s-ast_2.10-3.2.10.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/com.thoughtworks.paranamer/paranamer/jars/paranamer-2.6.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.spire-math/jawn-parser_2.10/jars/jawn-parser_2.10-0.6.0.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.spire-math/json4s-support_2.10/jars/json4s-support_2.10-0.6.0.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/run/jars/run-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/task-system/jars/task-system-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/tasks/jars/tasks-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/tracking/jars/tracking-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/cache/jars/cache-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/testing/jars/testing-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/test-agent/jars/test-agent-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/test-interface/jars/test-interface-1.0.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/main-settings/jars/main-settings-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/apply-macro/jars/apply-macro-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/command/jars/command-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/logic/jars/logic-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/compiler-interface/jars/compiler-interface-bin-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/compiler-interface/jars/compiler-interface-src-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/precompiled-2_8_2/jars/compiler-interface-bin-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/precompiled-2_9_2/jars/compiler-interface-bin-0.13.11.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/precompiled-2_9_3/jars/compiler-interface-bin-0.13.11.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES>
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/main/srcs/main-0.13.11-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.10.5-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-lang/scala-reflect/srcs/scala-reflect-2.10.5-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-lang/scala-compiler/srcs/scala-compiler-2.10.5-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/actions/srcs/actions-0.13.11-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/sbt/srcs/sbt-0.13.11-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/run/srcs/run-0.13.11-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/test-interface/srcs/test-interface-1.0-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/testing/srcs/testing-0.13.11-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/tasks/srcs/tasks-0.13.11-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/ivy/srcs/ivy-0.13.11-sources.jar!/" />
+ <root url="jar://$USER_HOME$/.ivy2/cache/org.scala-sbt/completion/srcs/completion-0.13.11-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ </component>
+</module>
diff --git a/src/intellij/scala.ipr.SAMPLE b/src/intellij/scala.ipr.SAMPLE
index 47ac2be188..420f559097 100644
--- a/src/intellij/scala.ipr.SAMPLE
+++ b/src/intellij/scala.ipr.SAMPLE
@@ -46,6 +46,7 @@
<module fileurl="file://$PROJECT_DIR$/reflect.iml" filepath="$PROJECT_DIR$/reflect.iml" />
<module fileurl="file://$PROJECT_DIR$/repl.iml" filepath="$PROJECT_DIR$/repl.iml" />
<module fileurl="file://$PROJECT_DIR$/scala.iml" filepath="$PROJECT_DIR$/scala.iml" />
+ <module fileurl="file://$PROJECT_DIR$/scala-build.iml" filepath="$PROJECT_DIR$/scala-build.iml" />
<module fileurl="file://$PROJECT_DIR$/scaladoc.iml" filepath="$PROJECT_DIR$/scaladoc.iml" />
<module fileurl="file://$PROJECT_DIR$/scalap.iml" filepath="$PROJECT_DIR$/scalap.iml" />
<module fileurl="file://$PROJECT_DIR$/test.iml" filepath="$PROJECT_DIR$/test.iml" />
@@ -125,4 +126,4 @@
<SOURCES />
</library>
</component>
-</project> \ No newline at end of file
+</project>
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/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/Product1.scala b/src/library/scala/Product1.scala
index dbc34ba66a..e82300adf6 100644
--- a/src/library/scala/Product1.scala
+++ b/src/library/scala/Product1.scala
@@ -24,7 +24,7 @@ trait Product1[@specialized(Int, Long, Double) +T1] extends Any with Product {
override def productArity = 1
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product10.scala b/src/library/scala/Product10.scala
index 70de79d49a..5fc4874048 100644
--- a/src/library/scala/Product10.scala
+++ b/src/library/scala/Product10.scala
@@ -24,7 +24,7 @@ trait Product10[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10] extends Any w
override def productArity = 10
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product11.scala b/src/library/scala/Product11.scala
index 1bb79ac017..dcebc90e3e 100644
--- a/src/library/scala/Product11.scala
+++ b/src/library/scala/Product11.scala
@@ -24,7 +24,7 @@ trait Product11[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11] extends
override def productArity = 11
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product12.scala b/src/library/scala/Product12.scala
index d7e1e1b05c..2221170452 100644
--- a/src/library/scala/Product12.scala
+++ b/src/library/scala/Product12.scala
@@ -24,7 +24,7 @@ trait Product12[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12] e
override def productArity = 12
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product13.scala b/src/library/scala/Product13.scala
index 8571b45a40..e76f326766 100644
--- a/src/library/scala/Product13.scala
+++ b/src/library/scala/Product13.scala
@@ -24,7 +24,7 @@ trait Product13[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +
override def productArity = 13
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product14.scala b/src/library/scala/Product14.scala
index a2f5140370..a076e2cc7a 100644
--- a/src/library/scala/Product14.scala
+++ b/src/library/scala/Product14.scala
@@ -24,7 +24,7 @@ trait Product14[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +
override def productArity = 14
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product15.scala b/src/library/scala/Product15.scala
index 1c6ad0011c..4568aff1fe 100644
--- a/src/library/scala/Product15.scala
+++ b/src/library/scala/Product15.scala
@@ -24,7 +24,7 @@ trait Product15[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +
override def productArity = 15
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product16.scala b/src/library/scala/Product16.scala
index f03b0b34a2..84dccb0ac8 100644
--- a/src/library/scala/Product16.scala
+++ b/src/library/scala/Product16.scala
@@ -24,7 +24,7 @@ trait Product16[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +
override def productArity = 16
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product17.scala b/src/library/scala/Product17.scala
index 72df1b496a..0d50898bf4 100644
--- a/src/library/scala/Product17.scala
+++ b/src/library/scala/Product17.scala
@@ -24,7 +24,7 @@ trait Product17[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +
override def productArity = 17
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product18.scala b/src/library/scala/Product18.scala
index 0402f90a01..9b32265d71 100644
--- a/src/library/scala/Product18.scala
+++ b/src/library/scala/Product18.scala
@@ -24,7 +24,7 @@ trait Product18[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +
override def productArity = 18
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product19.scala b/src/library/scala/Product19.scala
index b9770db47b..fe6b95669b 100644
--- a/src/library/scala/Product19.scala
+++ b/src/library/scala/Product19.scala
@@ -24,7 +24,7 @@ trait Product19[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +
override def productArity = 19
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product2.scala b/src/library/scala/Product2.scala
index a43a4a285c..091bcc89de 100644
--- a/src/library/scala/Product2.scala
+++ b/src/library/scala/Product2.scala
@@ -24,7 +24,7 @@ trait Product2[@specialized(Int, Long, Double) +T1, @specialized(Int, Long, Doub
override def productArity = 2
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product20.scala b/src/library/scala/Product20.scala
index 7b0df201ec..81315e3558 100644
--- a/src/library/scala/Product20.scala
+++ b/src/library/scala/Product20.scala
@@ -24,7 +24,7 @@ trait Product20[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +
override def productArity = 20
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product21.scala b/src/library/scala/Product21.scala
index f81347aac0..b5967c06e1 100644
--- a/src/library/scala/Product21.scala
+++ b/src/library/scala/Product21.scala
@@ -24,7 +24,7 @@ trait Product21[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +
override def productArity = 21
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product22.scala b/src/library/scala/Product22.scala
index 7a25891c6e..c7b9da5ce8 100644
--- a/src/library/scala/Product22.scala
+++ b/src/library/scala/Product22.scala
@@ -24,7 +24,7 @@ trait Product22[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +
override def productArity = 22
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product3.scala b/src/library/scala/Product3.scala
index 9976240935..7154bf5bdf 100644
--- a/src/library/scala/Product3.scala
+++ b/src/library/scala/Product3.scala
@@ -24,7 +24,7 @@ trait Product3[+T1, +T2, +T3] extends Any with Product {
override def productArity = 3
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product4.scala b/src/library/scala/Product4.scala
index d6c1543390..046f8c7a7c 100644
--- a/src/library/scala/Product4.scala
+++ b/src/library/scala/Product4.scala
@@ -24,7 +24,7 @@ trait Product4[+T1, +T2, +T3, +T4] extends Any with Product {
override def productArity = 4
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product5.scala b/src/library/scala/Product5.scala
index 5f1b11a30d..3e952c8c55 100644
--- a/src/library/scala/Product5.scala
+++ b/src/library/scala/Product5.scala
@@ -24,7 +24,7 @@ trait Product5[+T1, +T2, +T3, +T4, +T5] extends Any with Product {
override def productArity = 5
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product6.scala b/src/library/scala/Product6.scala
index efd9408d73..010c68711a 100644
--- a/src/library/scala/Product6.scala
+++ b/src/library/scala/Product6.scala
@@ -24,7 +24,7 @@ trait Product6[+T1, +T2, +T3, +T4, +T5, +T6] extends Any with Product {
override def productArity = 6
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product7.scala b/src/library/scala/Product7.scala
index fab0a997a1..24e5a5c05a 100644
--- a/src/library/scala/Product7.scala
+++ b/src/library/scala/Product7.scala
@@ -24,7 +24,7 @@ trait Product7[+T1, +T2, +T3, +T4, +T5, +T6, +T7] extends Any with Product {
override def productArity = 7
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product8.scala b/src/library/scala/Product8.scala
index 41391f7050..4a9f65b00e 100644
--- a/src/library/scala/Product8.scala
+++ b/src/library/scala/Product8.scala
@@ -24,7 +24,7 @@ trait Product8[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8] extends Any with Product
override def productArity = 8
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
diff --git a/src/library/scala/Product9.scala b/src/library/scala/Product9.scala
index e22538e1ee..9af11f709a 100644
--- a/src/library/scala/Product9.scala
+++ b/src/library/scala/Product9.scala
@@ -24,7 +24,7 @@ trait Product9[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9] extends Any with Pro
override def productArity = 9
- /** Returns the n-th projection of this product if 0 < n <= productArity,
+ /** Returns the n-th projection of this product if 0 <= n < productArity,
* otherwise throws an `IndexOutOfBoundsException`.
*
* @param n number of the projection to be returned
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/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala
index 8a8af79151..29369447d1 100644
--- a/src/library/scala/collection/BitSetLike.scala
+++ b/src/library/scala/collection/BitSetLike.scala
@@ -115,7 +115,7 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe
else Iterator.empty.next()
}
- override def foreach[B](f: Int => B) {
+ override def foreach[U](f: Int => U) {
/* NOTE: while loops are significantly faster as of 2.11 and
one major use case of bitsets is performance. Also, there
is nothing to do when all bits are clear, so use that as
diff --git a/src/library/scala/collection/GenMapLike.scala b/src/library/scala/collection/GenMapLike.scala
index bce9740522..2b39fa2289 100644
--- a/src/library/scala/collection/GenMapLike.scala
+++ b/src/library/scala/collection/GenMapLike.scala
@@ -124,8 +124,7 @@ trait GenMapLike[A, +B, +Repr] extends GenIterableLike[(A, B), Repr] with Equals
}
}
} catch {
- case ex: ClassCastException =>
- println("class cast "); false
+ case ex: ClassCastException => false
}}
case _ =>
false
diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala
index 8b9d3e7a17..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.
@@ -269,16 +257,16 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with
* {{{
* scala> val a = List(1)
* a: List[Int] = List(1)
- *
+ *
* scala> val b = List(2)
* b: List[Int] = List(2)
- *
+ *
* scala> val c = a ++ b
* c: List[Int] = List(1, 2)
- *
+ *
* scala> val d = List('a')
* d: List[Char] = List(a)
- *
+ *
* scala> val e = c ++ d
* e: List[AnyVal] = List(1, 2, a)
* }}}
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index f77462ce88..4af2ca23be 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -49,8 +49,41 @@ 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
+ /** Tests whether this $coll is known to have a finite size.
+ * All strict collections are known to have finite size. For a non-strict
+ * collection such as `Stream`, the predicate returns `'''true'''` if all
+ * elements have been computed. It returns `'''false'''` if the stream is
+ * not yet evaluated to the end. Non-empty Iterators usually return
+ * `'''false'''` even if they were created from a collection with a known
+ * finite size.
+ *
+ * Note: many collection methods will not work on collections of infinite sizes.
+ * The typical failure mode is an infinite loop. These methods always attempt a
+ * traversal without checking first that `hasDefiniteSize` returns `'''true'''`.
+ * However, checking `hasDefiniteSize` can provide an assurance that size is
+ * well-defined and non-termination is not a concern.
+ *
+ * @return `'''true'''` if this collection is known to have finite size,
+ * `'''false'''` otherwise.
+ */
def hasDefiniteSize: Boolean
def seq: TraversableOnce[A]
@@ -65,6 +98,9 @@ trait GenTraversableOnce[+A] extends Any {
/** Tests whether the $coll is empty.
*
+ * Note: Implementations in subclasses that are not repeatedly traversable must take
+ * care not to consume any elements when `isEmpty` is called.
+ *
* @return `true` if the $coll contains no elements, `false` otherwise.
*/
def isEmpty: Boolean
@@ -110,13 +146,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 +242,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 +260,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.
@@ -393,28 +433,43 @@ trait GenTraversableOnce[+A] extends Any {
*/
def minBy[B](f: A => B)(implicit cmp: Ordering[B]): A
- def forall(pred: A => Boolean): Boolean
+ /** 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 or the given predicate `p`
+ * holds for all elements of this $coll, otherwise `false`.
+ */
+ def forall(@deprecatedName('pred) p: A => Boolean): Boolean
- def exists(pred: A => Boolean): Boolean
+ /** Tests whether a predicate holds for at least one element of this $coll.
+ *
+ * $mayNotTerminateInf
+ *
+ * @param p the predicate used to test elements.
+ * @return `true` if the given predicate `p` is satisfied by at least one element of this $coll, otherwise `false`
+ */
+ def exists(@deprecatedName('pred) p: A => Boolean): Boolean
/** Finds the first element of the $coll satisfying a predicate, if any.
*
* $mayNotTerminateInf
* $orderDependent
*
- * @param pred the predicate used to test elements.
+ * @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(pred: A => Boolean): Option[A]
+ 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
@@ -423,14 +478,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
@@ -439,6 +494,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/Iterator.scala b/src/library/scala/collection/Iterator.scala
index b69e51fdf5..8d88b1c6b1 100644
--- a/src/library/scala/collection/Iterator.scala
+++ b/src/library/scala/collection/Iterator.scala
@@ -10,7 +10,7 @@ package scala
package collection
import mutable.ArrayBuffer
-import scala.annotation.migration
+import scala.annotation.{tailrec, migration}
import immutable.Stream
import scala.collection.generic.CanBuildFrom
import scala.annotation.unchecked.{ uncheckedVariance => uV }
@@ -168,8 +168,10 @@ object Iterator {
private[scala] final class ConcatIterator[+A](private[this] var current: Iterator[A], initial: Vector[() => Iterator[A]]) extends Iterator[A] {
@deprecated def this(initial: Vector[() => Iterator[A]]) = this(Iterator.empty, initial) // for binary compatibility
private[this] var queue: Vector[() => Iterator[A]] = initial
+ private[this] var currentHasNextChecked = false
// Advance current to the next non-empty iterator
// current is set to null when all iterators are exhausted
+ @tailrec
private[this] def advance(): Boolean = {
if (queue.isEmpty) {
current = null
@@ -178,20 +180,57 @@ object Iterator {
else {
current = queue.head()
queue = queue.tail
- current.hasNext || advance()
+ if (current.hasNext) {
+ currentHasNextChecked = true
+ true
+ } else advance()
}
}
- def hasNext = (current ne null) && (current.hasNext || advance())
- def next() = if (hasNext) current.next else Iterator.empty.next
+ def hasNext =
+ if (currentHasNextChecked) true
+ else if (current eq null) false
+ else if (current.hasNext) {
+ currentHasNextChecked = true
+ true
+ } else advance()
+ def next() =
+ if (hasNext) {
+ currentHasNextChecked = false
+ current.next()
+ } else Iterator.empty.next()
override def ++[B >: A](that: => GenTraversableOnce[B]): Iterator[B] =
new ConcatIterator(current, queue :+ (() => that.toIterator))
}
private[scala] final class JoinIterator[+A](lhs: Iterator[A], that: => GenTraversableOnce[A]) extends Iterator[A] {
+ private[this] var state = 0 // 0: lhs not checked, 1: lhs has next, 2: switched to rhs
private[this] lazy val rhs: Iterator[A] = that.toIterator
- def hasNext = lhs.hasNext || rhs.hasNext
- def next = if (lhs.hasNext) lhs.next else rhs.next
+ def hasNext = state match {
+ case 0 =>
+ if (lhs.hasNext) {
+ state = 1
+ true
+ } else {
+ state = 2
+ rhs.hasNext
+ }
+ case 1 => true
+ case _ => rhs.hasNext
+ }
+ def next() = state match {
+ case 0 =>
+ if (lhs.hasNext) lhs.next()
+ else {
+ state = 2
+ rhs.next()
+ }
+ case 1 =>
+ state = 0
+ lhs.next()
+ case _ =>
+ rhs.next()
+ }
override def ++[B >: A](that: => GenTraversableOnce[B]) =
new ConcatIterator(this, Vector(() => that.toIterator))
@@ -851,7 +890,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
* @usecase def foreach(f: A => Unit): Unit
* @inheritdoc
*/
- def foreach[U](f: A => U) { while (hasNext) f(next()) }
+ def foreach[U](f: A => U) { while (hasNext) f(next()) }
/** Tests whether a predicate holds for all values produced by this iterator.
* $mayNotTerminateInf
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/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala
index 9c336e8e31..b7af8840a9 100644
--- a/src/library/scala/collection/LinearSeqOptimized.scala
+++ b/src/library/scala/collection/LinearSeqOptimized.scala
@@ -67,7 +67,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea
}
override /*IterableLike*/
- def foreach[B](f: A => B) {
+ def foreach[U](f: A => U) {
var these = this
while (!these.isEmpty) {
f(these.head)
@@ -117,20 +117,20 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea
}
override /*TraversableLike*/
- def foldLeft[B](z: B)(f: (B, A) => B): B = {
+ def foldLeft[B](z: B)(@deprecatedName('f) op: (B, A) => B): B = {
var acc = z
var these = this
while (!these.isEmpty) {
- acc = f(acc, these.head)
+ acc = op(acc, these.head)
these = these.tail
}
acc
}
override /*IterableLike*/
- def foldRight[B](z: B)(f: (A, B) => B): B =
+ def foldRight[B](z: B)(@deprecatedName('f) op: (A, B) => B): B =
if (this.isEmpty) z
- else f(head, tail.foldRight(z)(f))
+ else op(head, tail.foldRight(z)(op))
override /*TraversableLike*/
def reduceLeft[B >: A](f: (B, A) => B): B =
diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala
index d133400570..99ed67325c 100644
--- a/src/library/scala/collection/MapLike.scala
+++ b/src/library/scala/collection/MapLike.scala
@@ -171,7 +171,7 @@ self =>
def + (elem: A): Set[A] = (Set[A]() ++ this + elem).asInstanceOf[Set[A]] // !!! concrete overrides abstract problem
def - (elem: A): Set[A] = (Set[A]() ++ this - elem).asInstanceOf[Set[A]] // !!! concrete overrides abstract problem
override def size = self.size
- override def foreach[C](f: A => C) = self.keysIterator foreach f
+ override def foreach[U](f: A => U) = self.keysIterator foreach f
}
/** Creates an iterator for all keys.
@@ -203,7 +203,7 @@ self =>
protected class DefaultValuesIterable extends AbstractIterable[B] with Iterable[B] with Serializable {
def iterator = valuesIterator
override def size = self.size
- override def foreach[C](f: B => C) = self.valuesIterator foreach f
+ override def foreach[U](f: B => U) = self.valuesIterator foreach f
}
/** Creates an iterator for all values in this map.
@@ -228,7 +228,7 @@ self =>
throw new NoSuchElementException("key not found: " + key)
protected class FilteredKeys(p: A => Boolean) extends AbstractMap[A, B] with DefaultMap[A, B] {
- override def foreach[C](f: ((A, B)) => C): Unit = for (kv <- self) if (p(kv._1)) f(kv)
+ override def foreach[U](f: ((A, B)) => U): Unit = for (kv <- self) if (p(kv._1)) f(kv)
def iterator = self.iterator.filter(kv => p(kv._1))
override def contains(key: A) = self.contains(key) && p(key)
def get(key: A) = if (!p(key)) None else self.get(key)
@@ -242,7 +242,7 @@ self =>
def filterKeys(p: A => Boolean): Map[A, B] = new FilteredKeys(p)
protected class MappedValues[C](f: B => C) extends AbstractMap[A, C] with DefaultMap[A, C] {
- override def foreach[D](g: ((A, C)) => D): Unit = for ((k, v) <- self) g((k, f(v)))
+ override def foreach[U](g: ((A, C)) => U): Unit = for ((k, v) <- self) g((k, f(v)))
def iterator = for ((k, v) <- self.iterator) yield (k, f(v))
override def size = self.size
override def contains(key: A) = self.contains(key)
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/Traversable.scala b/src/library/scala/collection/Traversable.scala
index a35750a35f..8145eaa204 100644
--- a/src/library/scala/collection/Traversable.scala
+++ b/src/library/scala/collection/Traversable.scala
@@ -38,7 +38,7 @@ trait Traversable[+A] extends TraversableLike[A, Traversable[A]]
override def remove(p: A => Boolean): Traversable[A]
override def partition(p: A => Boolean): (Traversable[A], Traversable[A])
override def groupBy[K](f: A => K): Map[K, Traversable[A]]
- override def foreach[U](f: A => U): Unit
+ override def foreach[U](f: A => U): Unit
override def forall(p: A => Boolean): Boolean
override def exists(p: A => Boolean): Boolean
override def count(p: A => Boolean): Int
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala
index 96374ef653..bbbc33b3f5 100644
--- a/src/library/scala/collection/TraversableLike.scala
+++ b/src/library/scala/collection/TraversableLike.scala
@@ -138,17 +138,6 @@ trait TraversableLike[+A, +Repr] extends Any
result
}
- /** Tests whether this $coll is known to have a finite size.
- * All strict collections are known to have finite size. For a non-strict
- * collection such as `Stream`, the predicate returns `'''true'''` if all
- * elements have been computed. It returns `'''false'''` if the stream is
- * not yet evaluated to the end.
- *
- * Note: many collection methods will not work on collections of infinite sizes.
- *
- * @return `'''true'''` if this collection is known to have finite size,
- * `'''false'''` otherwise.
- */
def hasDefiniteSize = true
def ++[B >: A, That](that: GenTraversableOnce[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
@@ -340,14 +329,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 {
@@ -357,7 +338,7 @@ trait TraversableLike[+A, +Repr] extends Any
result
}
- /** Tests whether a predicate holds for some of the elements of this $coll.
+ /** Tests whether a predicate holds for at least one element of this $coll.
*
* $mayNotTerminateInf
*
@@ -374,15 +355,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 +566,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 +580,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/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala
index c5b0d0f085..75c0d82922 100644
--- a/src/library/scala/collection/TraversableOnce.scala
+++ b/src/library/scala/collection/TraversableOnce.scala
@@ -38,9 +38,10 @@ import scala.reflect.ClassTag
* `Traversables`, such as folds, conversions, and other operations which
* traverse some or all of the elements and return a derived value.
* Directly subclassing `TraversableOnce` is not recommended - instead,
- * consider declaring an `Iterator` with a `next` and `hasNext` method,
- * creating an `Iterator` with one of the methods on the `Iterator` object,
- * or declaring a subclass of `Traversable`.
+ * consider declaring an `Iterator` with a `next` and `hasNext` method or
+ * creating an `Iterator` with one of the methods on the `Iterator` object.
+ * Consider declaring a subclass of `Traversable` instead if the elements
+ * can be traversed repeatedly.
*
* @define coll traversable or iterator
* @define orderDependent
@@ -61,7 +62,8 @@ import scala.reflect.ClassTag
trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
self =>
- /** Self-documenting abstract methods. */
+ //TODO 2.12: Remove these methods. They are already defined in GenTraversableOnce
+ /* Self-documenting abstract methods. */
def foreach[U](f: A => U): Unit
def isEmpty: Boolean
def hasDefiniteSize: Boolean
@@ -334,10 +336,10 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
* {{{
* scala> val a = List(1,2,3,4)
* a: List[Int] = List(1, 2, 3, 4)
- *
+ *
* scala> val b = new StringBuilder()
- * b: StringBuilder =
- *
+ * b: StringBuilder =
+ *
* scala> a.addString(b , "List(" , ", " , ")")
* res5: StringBuilder = List(1, 2, 3, 4)
* }}}
@@ -376,7 +378,7 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
* {{{
* scala> val a = List(1,2,3,4)
* a: List[Int] = List(1, 2, 3, 4)
- *
+ *
* scala> val b = new StringBuilder()
* b: StringBuilder =
*
@@ -399,7 +401,7 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
* {{{
* scala> val a = List(1,2,3,4)
* a: List[Int] = List(1, 2, 3, 4)
- *
+ *
* scala> val b = new StringBuilder()
* b: StringBuilder =
*
diff --git a/src/library/scala/collection/TraversableProxyLike.scala b/src/library/scala/collection/TraversableProxyLike.scala
index 4399dbc289..fa470ea238 100644
--- a/src/library/scala/collection/TraversableProxyLike.scala
+++ b/src/library/scala/collection/TraversableProxyLike.scala
@@ -28,7 +28,7 @@ import scala.reflect.ClassTag
trait TraversableProxyLike[+A, +Repr <: TraversableLike[A, Repr] with Traversable[A]] extends TraversableLike[A, Repr] with Proxy {
def self: Repr
- override def foreach[B](f: A => B): Unit = self.foreach(f)
+ override def foreach[U](f: A => U): Unit = self.foreach(f)
override def isEmpty: Boolean = self.isEmpty
override def nonEmpty: Boolean = self.nonEmpty
override def size: Int = self.size
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/generic/TraversableForwarder.scala b/src/library/scala/collection/generic/TraversableForwarder.scala
index 1d7974f7a4..359ea402b6 100644
--- a/src/library/scala/collection/generic/TraversableForwarder.scala
+++ b/src/library/scala/collection/generic/TraversableForwarder.scala
@@ -32,7 +32,7 @@ trait TraversableForwarder[+A] extends Traversable[A] {
/** The traversable object to which calls are forwarded. */
protected def underlying: Traversable[A]
- override def foreach[B](f: A => B): Unit = underlying foreach f
+ override def foreach[U](f: A => U): Unit = underlying foreach f
override def isEmpty: Boolean = underlying.isEmpty
override def nonEmpty: Boolean = underlying.nonEmpty
override def size: Int = underlying.size
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index 3b3e65ea61..92d915fe8b 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -48,7 +48,7 @@ class HashMap[A, +B] extends AbstractMap[A, B]
def iterator: Iterator[(A,B)] = Iterator.empty
- override def foreach[U](f: ((A, B)) => U): Unit = { }
+ override def foreach[U](f: ((A, B)) => U): Unit = ()
def get(key: A): Option[B] =
get0(key, computeHash(key), 0)
@@ -422,7 +422,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
final override def getElem(cc: AnyRef): (A, B) = cc.asInstanceOf[HashMap1[A, B]].ensurePair
}
- override def foreach[U](f: ((A, B)) => U): Unit = {
+ override def foreach[U](f: ((A, B)) => U): Unit = {
var i = 0
while (i < elems.length) {
elems(i).foreach(f)
diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala
index 27b2bfdde7..050e90b49b 100644
--- a/src/library/scala/collection/immutable/HashSet.scala
+++ b/src/library/scala/collection/immutable/HashSet.scala
@@ -53,7 +53,7 @@ class HashSet[A] extends AbstractSet[A]
def iterator: Iterator[A] = Iterator.empty
- override def foreach[U](f: A => U): Unit = { }
+ override def foreach[U](f: A => U): Unit = ()
def contains(e: A): Boolean = get0(e, computeHash(e), 0)
@@ -215,7 +215,7 @@ object HashSet extends ImmutableSetFactory[HashSet] {
private object EmptyHashSet extends HashSet[Any] { }
private[collection] def emptyInstance: HashSet[Any] = EmptyHashSet
-
+
// utility method to create a HashTrieSet from two leaf HashSets (HashSet1 or HashSetCollision1) with non-colliding hash code)
private def makeHashTrieSet[A](hash0:Int, elem0:HashSet[A], hash1:Int, elem1:HashSet[A], level:Int) : HashTrieSet[A] = {
val index0 = (hash0 >>> level) & 0x1f
@@ -966,7 +966,7 @@ object HashSet extends ImmutableSetFactory[HashSet] {
final override def getElem(cc: AnyRef): A = cc.asInstanceOf[HashSet1[A]].key
}
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
var i = 0
while (i < elems.length) {
elems(i).foreach(f)
diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala
index cb6196e130..c6bf6a77e8 100644
--- a/src/library/scala/collection/immutable/IntMap.scala
+++ b/src/library/scala/collection/immutable/IntMap.scala
@@ -184,7 +184,7 @@ sealed abstract class IntMap[+T] extends AbstractMap[Int, T]
/**
* Loops over the key, value pairs of the map in unsigned order of the keys.
*/
- override final def foreach[U](f: ((Int, T)) => U): Unit = this match {
+ override final def foreach[U](f: ((Int, T)) => U): Unit = this match {
case IntMap.Bin(_, _, left, right) => { left.foreach(f); right.foreach(f) }
case IntMap.Tip(key, value) => f((key, value))
case IntMap.Nil =>
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index 53146bd66d..75ddded6d2 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -25,6 +25,19 @@ import java.io._
* This class is optimal for last-in-first-out (LIFO), stack-like access patterns. If you need another access
* pattern, for example, random access or FIFO, consider using a collection more suited to this than `List`.
*
+ * ==Performance==
+ * '''Time:''' `List` has `O(1)` prepend and head/tail access. Most other operations are `O(n)` on the number of elements in the list.
+ * This includes the index-based lookup of elements, `length`, `append` and `reverse`.
+ *
+ * '''Space:''' `List` implements '''structural sharing''' of the tail list. This means that many operations are either
+ * zero- or constant-memory cost.
+ * {{{
+ * val mainList = List(3, 2, 1)
+ * val with4 = 4 :: mainList // re-uses mainList, costs one :: instance
+ * val with42 = 42 :: mainList // also re-uses mainList, cost one :: instance
+ * val shorter = mainList.tail // costs nothing as it uses the same 2::1::Nil instances as mainList
+ * }}}
+ *
* @example {{{
* // Make a list via the companion object factory
* val days = List("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
@@ -41,19 +54,6 @@ import java.io._
* }
* }}}
*
- * ==Performance==
- * '''Time:''' `List` has `O(1)` prepend and head/tail access. Most other operations are `O(n)` on the number of elements in the list.
- * This includes the index-based lookup of elements, `length`, `append` and `reverse`.
- *
- * '''Space:''' `List` implements '''structural sharing''' of the tail list. This means that many operations are either
- * zero- or constant-memory cost.
- * {{{
- * val mainList = List(3, 2, 1)
- * val with4 = 4 :: mainList // re-uses mainList, costs one :: instance
- * val with42 = 42 :: mainList // also re-uses mainList, cost one :: instance
- * val shorter = mainList.tail // costs nothing as it uses the same 2::1::Nil instances as mainList
- * }}}
- *
* @note The functional list is characterized by persistence and structural sharing, thus offering considerable
* performance and space consumption benefits in some scenarios if used correctly.
* However, note that objects having multiple references into the same functional list (that is,
diff --git a/src/library/scala/collection/immutable/LongMap.scala b/src/library/scala/collection/immutable/LongMap.scala
index 868c0c0f47..173d912fe5 100644
--- a/src/library/scala/collection/immutable/LongMap.scala
+++ b/src/library/scala/collection/immutable/LongMap.scala
@@ -176,7 +176,7 @@ extends AbstractMap[Long, T]
/**
* Loops over the key, value pairs of the map in unsigned order of the keys.
*/
- override final def foreach[U](f: ((Long, T)) => U): Unit = this match {
+ override final def foreach[U](f: ((Long, T)) => U): Unit = this match {
case LongMap.Bin(_, _, left, right) => { left.foreach(f); right.foreach(f) }
case LongMap.Tip(key, value) => f((key, value))
case LongMap.Nil =>
diff --git a/src/library/scala/collection/immutable/Map.scala b/src/library/scala/collection/immutable/Map.scala
index 5178d5a862..2c5b444c70 100644
--- a/src/library/scala/collection/immutable/Map.scala
+++ b/src/library/scala/collection/immutable/Map.scala
@@ -112,7 +112,7 @@ object Map extends ImmutableMapFactory[Map] {
def + [B1 >: B](kv: (A, B1)): Map[A, B1] = updated(kv._1, kv._2)
def - (key: A): Map[A, B] =
if (key == key1) Map.empty else this
- override def foreach[U](f: ((A, B)) => U): Unit = {
+ override def foreach[U](f: ((A, B)) => U): Unit = {
f((key1, value1))
}
}
@@ -133,7 +133,7 @@ object Map extends ImmutableMapFactory[Map] {
if (key == key1) new Map1(key2, value2)
else if (key == key2) new Map1(key1, value1)
else this
- override def foreach[U](f: ((A, B)) => U): Unit = {
+ override def foreach[U](f: ((A, B)) => U): Unit = {
f((key1, value1)); f((key2, value2))
}
}
@@ -157,7 +157,7 @@ object Map extends ImmutableMapFactory[Map] {
else if (key == key2) new Map2(key1, value1, key3, value3)
else if (key == key3) new Map2(key1, value1, key2, value2)
else this
- override def foreach[U](f: ((A, B)) => U): Unit = {
+ override def foreach[U](f: ((A, B)) => U): Unit = {
f((key1, value1)); f((key2, value2)); f((key3, value3))
}
}
@@ -184,7 +184,7 @@ object Map extends ImmutableMapFactory[Map] {
else if (key == key3) new Map3(key1, value1, key2, value2, key4, value4)
else if (key == key4) new Map3(key1, value1, key2, value2, key3, value3)
else this
- override def foreach[U](f: ((A, B)) => U): Unit = {
+ override def foreach[U](f: ((A, B)) => U): Unit = {
f((key1, value1)); f((key2, value2)); f((key3, value3)); f((key4, value4))
}
}
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/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala
index 7e8cfcc902..afb4c9c552 100644
--- a/src/library/scala/collection/immutable/RedBlackTree.scala
+++ b/src/library/scala/collection/immutable/RedBlackTree.scala
@@ -409,11 +409,11 @@ object RedBlackTree {
def cons[B](x: B, xs: NList[B]): NList[B] = new NList(x, xs)
- def foldLeft[A, B](xs: NList[A], z: B)(f: (B, A) => B): B = {
+ def foldLeft[A, B](xs: NList[A], z: B)(op: (B, A) => B): B = {
var acc = z
var these = xs
while (these ne null) {
- acc = f(acc, these.head)
+ acc = op(acc, these.head)
these = these.tail
}
acc
diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala
index a115469b83..031e5248c1 100644
--- a/src/library/scala/collection/immutable/Set.scala
+++ b/src/library/scala/collection/immutable/Set.scala
@@ -33,7 +33,7 @@ trait Set[A] extends Iterable[A]
with Parallelizable[A, ParSet[A]]
{
override def companion: GenericCompanion[Set] = Set
-
+
/** Returns this $coll as an immutable set, perhaps accepting a
* wider range of elements. Since it already is an
@@ -63,7 +63,7 @@ trait Set[A] extends Iterable[A]
object Set extends ImmutableSetFactory[Set] {
/** $setCanBuildFromInfo */
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Set[A]] = setCanBuildFrom[A]
-
+
/** An optimized representation for immutable empty sets */
private object EmptySet extends AbstractSet[Any] with Set[Any] with Serializable {
override def size: Int = 0
@@ -71,7 +71,7 @@ object Set extends ImmutableSetFactory[Set] {
def + (elem: Any): Set[Any] = new Set1(elem)
def - (elem: Any): Set[Any] = this
def iterator: Iterator[Any] = Iterator.empty
- override def foreach[U](f: Any => U): Unit = {}
+ override def foreach[U](f: Any => U): Unit = ()
override def toSet[B >: Any]: Set[B] = this.asInstanceOf[Set[B]]
}
private[collection] def emptyInstance: Set[Any] = EmptySet
@@ -90,17 +90,17 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
else None
}
// Why is Set1 non-final? Need to fix that!
@@ -124,18 +124,18 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1, elem2)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1); f(elem2)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1) || f(elem2)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) || p(elem2)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1) && f(elem2)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) && p(elem2)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
- else if (f(elem2)) Some(elem2)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
+ else if (p(elem2)) Some(elem2)
else None
}
// Why is Set2 non-final? Need to fix that!
@@ -159,19 +159,19 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1, elem2, elem3)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1); f(elem2); f(elem3)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1) || f(elem2) || f(elem3)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) || p(elem2) || p(elem3)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1) && f(elem2) && f(elem3)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) && p(elem2) && p(elem3)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
- else if (f(elem2)) Some(elem2)
- else if (f(elem3)) Some(elem3)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
+ else if (p(elem2)) Some(elem2)
+ else if (p(elem3)) Some(elem3)
else None
}
// Why is Set3 non-final? Need to fix that!
@@ -196,20 +196,20 @@ object Set extends ImmutableSetFactory[Set] {
else this
def iterator: Iterator[A] =
Iterator(elem1, elem2, elem3, elem4)
- override def foreach[U](f: A => U): Unit = {
+ override def foreach[U](f: A => U): Unit = {
f(elem1); f(elem2); f(elem3); f(elem4)
}
- override def exists(f: A => Boolean): Boolean = {
- f(elem1) || f(elem2) || f(elem3) || f(elem4)
+ override def exists(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) || p(elem2) || p(elem3) || p(elem4)
}
- override def forall(f: A => Boolean): Boolean = {
- f(elem1) && f(elem2) && f(elem3) && f(elem4)
+ override def forall(@deprecatedName('f) p: A => Boolean): Boolean = {
+ p(elem1) && p(elem2) && p(elem3) && p(elem4)
}
- override def find(f: A => Boolean): Option[A] = {
- if (f(elem1)) Some(elem1)
- else if (f(elem2)) Some(elem2)
- else if (f(elem3)) Some(elem3)
- else if (f(elem4)) Some(elem4)
+ override def find(@deprecatedName('f) p: A => Boolean): Option[A] = {
+ if (p(elem1)) Some(elem1)
+ else if (p(elem2)) Some(elem2)
+ else if (p(elem3)) Some(elem3)
+ else if (p(elem4)) Some(elem4)
else None
}
// Why is Set4 non-final? Need to fix that!
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index a6c55f8828..d3be809255 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -176,9 +176,9 @@ import scala.language.implicitConversions
* loop(1, 1)
* }
* }}}
- *
+ *
* Note that `mkString` forces evaluation of a `Stream`, but `addString` does
- * not. In both cases, a `Stream` that is or ends in a cycle
+ * not. In both cases, a `Stream` that is or ends in a cycle
* (e.g. `lazy val s: Stream[Int] = 0 #:: s`) will convert additional trips
* through the cycle to `...`. Additionally, `addString` will display an
* un-memoized tail as `?`.
@@ -566,7 +566,7 @@ self =>
else super.flatMap(f)(bf)
}
- override def foreach[B](f: A => B) =
+ override def foreach[U](f: A => U) =
for (x <- self)
if (p(x)) f(x)
@@ -589,7 +589,7 @@ self =>
* unless the `f` throws an exception.
*/
@tailrec
- override final def foreach[B](f: A => B) {
+ override final def foreach[U](f: A => U) {
if (!this.isEmpty) {
f(head)
tail.foreach(f)
diff --git a/src/library/scala/collection/immutable/TreeMap.scala b/src/library/scala/collection/immutable/TreeMap.scala
index 662075cd93..b845b76026 100644
--- a/src/library/scala/collection/immutable/TreeMap.scala
+++ b/src/library/scala/collection/immutable/TreeMap.scala
@@ -200,5 +200,5 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi
override def contains(key: A): Boolean = RB.contains(tree, key)
override def isDefinedAt(key: A): Boolean = RB.contains(tree, key)
- override def foreach[U](f : ((A,B)) => U) = RB.foreach(tree, f)
+ override def foreach[U](f : ((A,B)) => U) = RB.foreach(tree, f)
}
diff --git a/src/library/scala/collection/immutable/TreeSet.scala b/src/library/scala/collection/immutable/TreeSet.scala
index 7378211db0..2800030d67 100644
--- a/src/library/scala/collection/immutable/TreeSet.scala
+++ b/src/library/scala/collection/immutable/TreeSet.scala
@@ -151,7 +151,7 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin
def iterator: Iterator[A] = RB.keysIterator(tree)
override def keysIteratorFrom(start: A): Iterator[A] = RB.keysIterator(tree, Some(start))
- override def foreach[U](f: A => U) = RB.foreachKey(tree, f)
+ override def foreach[U](f: A => U) = RB.foreachKey(tree, f)
override def rangeImpl(from: Option[A], until: Option[A]): TreeSet[A] = newSet(RB.rangeImpl(tree, from, until))
override def range(from: A, until: A): TreeSet[A] = newSet(RB.range(tree, from, until))
diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala
index 8bb581d44c..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
@@ -951,8 +951,6 @@ private[immutable] trait VectorPointer[T] {
// STUFF BELOW USED BY APPEND / UPDATE
private[immutable] final def copyOf(a: Array[AnyRef]) = {
- //println("copy")
- if (a eq null) println ("NULL")
val b = new Array[AnyRef](a.length)
Platform.arraycopy(a, 0, b, 0, a.length)
b
diff --git a/src/library/scala/collection/mutable/AnyRefMap.scala b/src/library/scala/collection/mutable/AnyRefMap.scala
index fccc9d83e6..369d596ec3 100644
--- a/src/library/scala/collection/mutable/AnyRefMap.scala
+++ b/src/library/scala/collection/mutable/AnyRefMap.scala
@@ -5,23 +5,23 @@ package mutable
import generic.CanBuildFrom
/** This class implements mutable maps with `AnyRef` keys based on a hash table with open addressing.
- *
- * Basic map operations on single entries, including `contains` and `get`,
+ *
+ * Basic map operations on single entries, including `contains` and `get`,
* are typically significantly faster with `AnyRefMap` than [[HashMap]].
* Note that numbers and characters are not handled specially in AnyRefMap;
* only plain `equals` and `hashCode` are used in comparisons.
- *
+ *
* Methods that traverse or regenerate the map, including `foreach` and `map`,
* are not in general faster than with `HashMap`. The methods `foreachKey`,
* `foreachValue`, `mapValuesNow`, and `transformValues` are, however, faster
* than alternative ways to achieve the same functionality.
- *
+ *
* Maps with open addressing may become less efficient at lookup after
* repeated addition/removal of elements. Although `AnyRefMap` makes a
* decent attempt to remain efficient regardless, calling `repack`
* on a map that will no longer have elements removed but will be
* used heavily may save both time and storage space.
- *
+ *
* This map is not intended to contain more than 2^29^ entries (approximately
* 500 million). The maximum capacity is 2^30^, but performance will degrade
* rapidly as 2^30^ is approached.
@@ -34,50 +34,50 @@ extends AbstractMap[K, V]
{
import AnyRefMap._
def this() = this(AnyRefMap.exceptionDefault, 16, true)
-
+
/** Creates a new `AnyRefMap` that returns default values according to a supplied key-value mapping. */
def this(defaultEntry: K => V) = this(defaultEntry, 16, true)
/** Creates a new `AnyRefMap` with an initial buffer of specified size.
- *
+ *
* An `AnyRefMap` can typically contain half as many elements as its buffer size
* before it requires resizing.
*/
def this(initialBufferSize: Int) = this(AnyRefMap.exceptionDefault, initialBufferSize, true)
-
+
/** Creates a new `AnyRefMap` with specified default values and initial buffer size. */
def this(defaultEntry: K => V, initialBufferSize: Int) = this(defaultEntry, initialBufferSize, true)
-
+
private[this] var mask = 0
private[this] var _size = 0
private[this] var _vacant = 0
private[this] var _hashes: Array[Int] = null
private[this] var _keys: Array[AnyRef] = null
private[this] var _values: Array[AnyRef] = null
-
+
if (initBlank) defaultInitialize(initialBufferSize)
-
+
private[this] def defaultInitialize(n: Int) {
- mask =
+ mask =
if (n<0) 0x7
else (((1 << (32 - java.lang.Integer.numberOfLeadingZeros(n-1))) - 1) & 0x3FFFFFFF) | 0x7
_hashes = new Array[Int](mask+1)
_keys = new Array[AnyRef](mask+1)
_values = new Array[AnyRef](mask+1)
}
-
+
private[collection] def initializeTo(
m: Int, sz: Int, vc: Int, hz: Array[Int], kz: Array[AnyRef], vz: Array[AnyRef]
) {
mask = m; _size = sz; _vacant = vc; _hashes = hz; _keys = kz; _values = vz
}
-
+
override def size: Int = _size
override def empty: AnyRefMap[K,V] = new AnyRefMap(defaultEntry)
-
- private def imbalanced: Boolean =
+
+ private def imbalanced: Boolean =
(_size + _vacant) > 0.5*mask || _vacant > _size
-
+
private def hashOf(key: K): Int = {
if (key eq null) 0x41081989
else {
@@ -88,7 +88,7 @@ extends AbstractMap[K, V]
if (j==0) 0x41081989 else j & 0x7FFFFFFF
}
}
-
+
private def seekEntry(h: Int, k: AnyRef): Int = {
var e = h & mask
var x = 0
@@ -100,7 +100,7 @@ extends AbstractMap[K, V]
}
e | MissingBit
}
-
+
private def seekEntryOrOpen(h: Int, k: AnyRef): Int = {
var e = h & mask
var x = 0
@@ -114,19 +114,19 @@ extends AbstractMap[K, V]
}
if (o >= 0) o | MissVacant else e | MissingBit
}
-
+
override def contains(key: K): Boolean = seekEntry(hashOf(key), key) >= 0
-
+
override def get(key: K): Option[V] = {
val i = seekEntry(hashOf(key), key)
if (i < 0) None else Some(_values(i).asInstanceOf[V])
}
-
+
override def getOrElse[V1 >: V](key: K, default: => V1): V1 = {
val i = seekEntry(hashOf(key), key)
if (i < 0) default else _values(i).asInstanceOf[V]
}
-
+
override def getOrElseUpdate(key: K, defaultValue: => V): V = {
val h = hashOf(key)
var i = seekEntryOrOpen(h, key)
@@ -154,10 +154,10 @@ extends AbstractMap[K, V]
}
else _values(i).asInstanceOf[V]
}
-
+
/** Retrieves the value associated with a key, or the default for that type if none exists
* (null for AnyRef, 0 for floats and integers).
- *
+ *
* Note: this is the fastest way to retrieve a value that may or
* may not exist, if the default null/zero is acceptable. For key/value
* pairs that do exist, `apply` (i.e. `map(key)`) is equally fast.
@@ -166,22 +166,22 @@ extends AbstractMap[K, V]
val i = seekEntry(hashOf(key), key)
(if (i < 0) null else _values(i)).asInstanceOf[V]
}
-
- /** Retrieves the value associated with a key.
+
+ /** Retrieves the value associated with a key.
* If the key does not exist in the map, the `defaultEntry` for that key
- * will be returned instead; an exception will be thrown if no
+ * will be returned instead; an exception will be thrown if no
* `defaultEntry` was supplied.
*/
override def apply(key: K): V = {
val i = seekEntry(hashOf(key), key)
if (i < 0) defaultEntry(key) else _values(i).asInstanceOf[V]
}
-
+
/** Defers to defaultEntry to find a default value for the key. Throws an
* exception if no other default behavior was specified.
*/
override def default(key: K) = defaultEntry(key)
-
+
private def repack(newMask: Int) {
val oh = _hashes
val ok = _keys
@@ -205,9 +205,9 @@ extends AbstractMap[K, V]
i += 1
}
}
-
+
/** Repacks the contents of this `AnyRefMap` for maximum efficiency of lookup.
- *
+ *
* For maps that undergo a complex creation process with both addition and
* removal of keys, and then are used heavily with no further removal of
* elements, calling `repack` after the end of the creation can result in
@@ -220,7 +220,7 @@ extends AbstractMap[K, V]
while (m > 8 && 8*_size < m) m = m >>> 1
repack(m)
}
-
+
override def put(key: K, value: V): Option[V] = {
val h = hashOf(key)
val k = key
@@ -243,9 +243,9 @@ extends AbstractMap[K, V]
ans
}
}
-
+
/** Updates the map to include a new key-value pair.
- *
+ *
* This is the fastest way to add an entry to an `AnyRefMap`.
*/
override def update(key: K, value: V): Unit = {
@@ -267,12 +267,12 @@ extends AbstractMap[K, V]
_values(i) = value.asInstanceOf[AnyRef]
}
}
-
+
/** Adds a new key/value pair to this map and returns the map. */
def +=(key: K, value: V): this.type = { update(key, value); this }
def +=(kv: (K, V)): this.type = { update(kv._1, kv._2); this }
-
+
def -=(key: K): this.type = {
val i = seekEntry(hashOf(key), key)
if (i >= 0) {
@@ -284,14 +284,14 @@ extends AbstractMap[K, V]
}
this
}
-
+
def iterator: Iterator[(K, V)] = new Iterator[(K, V)] {
private[this] val hz = _hashes
private[this] val kz = _keys
private[this] val vz = _values
-
+
private[this] var index = 0
-
+
def hasNext: Boolean = index<hz.length && {
var h = hz(index)
while (h+h == 0) {
@@ -301,7 +301,7 @@ extends AbstractMap[K, V]
}
true
}
-
+
def next: (K, V) = {
if (hasNext) {
val ans = (kz(index).asInstanceOf[K], vz(index).asInstanceOf[V])
@@ -311,8 +311,8 @@ extends AbstractMap[K, V]
else throw new NoSuchElementException("next")
}
}
-
- override def foreach[A](f: ((K,V)) => A) {
+
+ override def foreach[U](f: ((K,V)) => U) {
var i = 0
var e = _size
while (e > 0) {
@@ -325,7 +325,7 @@ extends AbstractMap[K, V]
else return
}
}
-
+
override def clone(): AnyRefMap[K, V] = {
val hz = java.util.Arrays.copyOf(_hashes, _hashes.length)
val kz = java.util.Arrays.copyOf(_keys, _keys.length)
@@ -334,7 +334,7 @@ extends AbstractMap[K, V]
arm.initializeTo(mask, _size, _vacant, hz, kz, vz)
arm
}
-
+
private[this] def foreachElement[A,B](elems: Array[AnyRef], f: A => B) {
var i,j = 0
while (i < _hashes.length & j < _size) {
@@ -346,13 +346,13 @@ extends AbstractMap[K, V]
i += 1
}
}
-
+
/** Applies a function to all keys of this map. */
def foreachKey[A](f: K => A) { foreachElement[K,A](_keys, f) }
/** Applies a function to all values of this map. */
def foreachValue[A](f: V => A) { foreachElement[V,A](_values, f) }
-
+
/** Creates a new `AnyRefMap` with different values.
* Unlike `mapValues`, this method generates a new
* collection immediately.
@@ -374,8 +374,8 @@ extends AbstractMap[K, V]
arm.initializeTo(mask, _size, _vacant, hz, kz, vz)
arm
}
-
- /** Applies a transformation function to all values stored in this map.
+
+ /** Applies a transformation function to all values stored in this map.
* Note: the default, if any, is not transformed.
*/
def transformValues(f: V => V): this.type = {
@@ -398,15 +398,15 @@ object AnyRefMap {
private final val MissingBit = 0x80000000
private final val VacantBit = 0x40000000
private final val MissVacant = 0xC0000000
-
+
private val exceptionDefault = (k: Any) => throw new NoSuchElementException(if (k == null) "(null)" else k.toString)
-
+
implicit def canBuildFrom[K <: AnyRef, V, J <: AnyRef, U]: CanBuildFrom[AnyRefMap[K,V], (J, U), AnyRefMap[J,U]] =
new CanBuildFrom[AnyRefMap[K,V], (J, U), AnyRefMap[J,U]] {
def apply(from: AnyRefMap[K,V]): AnyRefMapBuilder[J, U] = apply()
def apply(): AnyRefMapBuilder[J, U] = new AnyRefMapBuilder[J, U]
}
-
+
final class AnyRefMapBuilder[K <: AnyRef, V] extends Builder[(K, V), AnyRefMap[K, V]] {
private[collection] var elems: AnyRefMap[K, V] = new AnyRefMap[K, V]
def +=(entry: (K, V)): this.type = {
@@ -425,14 +425,14 @@ object AnyRefMap {
if (arm.size < (sz>>3)) arm.repack()
arm
}
-
+
/** Creates a new empty `AnyRefMap`. */
def empty[K <: AnyRef, V]: AnyRefMap[K, V] = new AnyRefMap[K, V]
-
+
/** Creates a new empty `AnyRefMap` with the supplied default */
def withDefault[K <: AnyRef, V](default: K => V): AnyRefMap[K, V] = new AnyRefMap[K, V](default)
-
- /** Creates a new `AnyRefMap` from arrays of keys and values.
+
+ /** Creates a new `AnyRefMap` from arrays of keys and values.
* Equivalent to but more efficient than `AnyRefMap((keys zip values): _*)`.
*/
def fromZip[K <: AnyRef, V](keys: Array[K], values: Array[V]): AnyRefMap[K, V] = {
@@ -443,8 +443,8 @@ object AnyRefMap {
if (arm.size < (sz>>3)) arm.repack()
arm
}
-
- /** Creates a new `AnyRefMap` from keys and values.
+
+ /** Creates a new `AnyRefMap` from keys and values.
* Equivalent to but more efficient than `AnyRefMap((keys zip values): _*)`.
*/
def fromZip[K <: AnyRef, V](keys: Iterable[K], values: Iterable[V]): AnyRefMap[K, V] = {
diff --git a/src/library/scala/collection/mutable/ArraySeq.scala b/src/library/scala/collection/mutable/ArraySeq.scala
index 577a838315..ddb48627af 100644
--- a/src/library/scala/collection/mutable/ArraySeq.scala
+++ b/src/library/scala/collection/mutable/ArraySeq.scala
@@ -68,7 +68,7 @@ extends AbstractSeq[A]
array(idx) = elem.asInstanceOf[AnyRef]
}
- override def foreach[U](f: A => U) {
+ override def foreach[U](f: A => U) {
var i = 0
while (i < length) {
f(array(i).asInstanceOf[A])
diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala
index fec2da8839..8ff128c026 100644
--- a/src/library/scala/collection/mutable/ArrayStack.scala
+++ b/src/library/scala/collection/mutable/ArrayStack.scala
@@ -233,7 +233,7 @@ extends AbstractSeq[T]
}
}
- override def foreach[U](f: T => U) {
+ override def foreach[U](f: T => U) {
var currentIndex = index
while (currentIndex > 0) {
currentIndex -= 1
diff --git a/src/library/scala/collection/mutable/HashMap.scala b/src/library/scala/collection/mutable/HashMap.scala
index 6fca75ffea..eab4202353 100644
--- a/src/library/scala/collection/mutable/HashMap.scala
+++ b/src/library/scala/collection/mutable/HashMap.scala
@@ -96,16 +96,16 @@ extends AbstractMap[A, B]
def iterator = entriesIterator map (e => ((e.key, e.value)))
- override def foreach[C](f: ((A, B)) => C): Unit = foreachEntry(e => f((e.key, e.value)))
+ override def foreach[U](f: ((A, B)) => U): Unit = foreachEntry(e => f((e.key, e.value)))
/* Override to avoid tuple allocation in foreach */
override def keySet: scala.collection.Set[A] = new DefaultKeySet {
- override def foreach[C](f: A => C) = foreachEntry(e => f(e.key))
+ override def foreach[U](f: A => U) = foreachEntry(e => f(e.key))
}
/* Override to avoid tuple allocation in foreach */
override def values: scala.collection.Iterable[B] = new DefaultValuesIterable {
- override def foreach[C](f: B => C) = foreachEntry(e => f(e.value))
+ override def foreach[U](f: B => U) = foreachEntry(e => f(e.value))
}
/* Override to avoid tuple allocation */
diff --git a/src/library/scala/collection/mutable/HashSet.scala b/src/library/scala/collection/mutable/HashSet.scala
index 886fee5a59..3a16e4efa5 100644
--- a/src/library/scala/collection/mutable/HashSet.scala
+++ b/src/library/scala/collection/mutable/HashSet.scala
@@ -70,7 +70,7 @@ extends AbstractSet[A]
override def iterator: Iterator[A] = super[FlatHashTable].iterator
- override def foreach[U](f: A => U) {
+ override def foreach[U](f: A => U) {
var i = 0
val len = table.length
while (i < len) {
diff --git a/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala b/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala
index 730b22227d..d7eec70b15 100644
--- a/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala
+++ b/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala
@@ -32,7 +32,7 @@ extends AbstractSet[A]
def contains(elem: A): Boolean = set.contains(elem)
- override def foreach[U](f: A => U): Unit = set.foreach(f)
+ override def foreach[U](f: A => U): Unit = set.foreach(f)
override def exists(p: A => Boolean): Boolean = set.exists(p)
diff --git a/src/library/scala/collection/mutable/LinkedListLike.scala b/src/library/scala/collection/mutable/LinkedListLike.scala
index a9d385bc5b..d0748b8a9f 100644
--- a/src/library/scala/collection/mutable/LinkedListLike.scala
+++ b/src/library/scala/collection/mutable/LinkedListLike.scala
@@ -172,7 +172,7 @@ trait LinkedListLike[A, This <: Seq[A] with LinkedListLike[A, This]] extends Seq
}
}
- override def foreach[B](f: A => B) {
+ override def foreach[U](f: A => U) {
var these = this
while (these.nonEmpty) {
f(these.elem)
diff --git a/src/library/scala/collection/mutable/LongMap.scala b/src/library/scala/collection/mutable/LongMap.scala
index c124f35cd7..198e34bd29 100644
--- a/src/library/scala/collection/mutable/LongMap.scala
+++ b/src/library/scala/collection/mutable/LongMap.scala
@@ -5,20 +5,20 @@ package mutable
import generic.CanBuildFrom
/** This class implements mutable maps with `Long` keys based on a hash table with open addressing.
- *
- * Basic map operations on single entries, including `contains` and `get`,
+ *
+ * Basic map operations on single entries, including `contains` and `get`,
* are typically substantially faster with `LongMap` than [[HashMap]]. Methods
* that act on the whole map, including `foreach` and `map` are not in
* general expected to be faster than with a generic map, save for those
* that take particular advantage of the internal structure of the map:
* `foreachKey`, `foreachValue`, `mapValuesNow`, and `transformValues`.
- *
+ *
* Maps with open addressing may become less efficient at lookup after
* repeated addition/removal of elements. Although `LongMap` makes a
* decent attempt to remain efficient regardless, calling `repack`
* on a map that will no longer have elements removed but will be
* used heavily may save both time and storage space.
- *
+ *
* This map is not intended to contain more than 2^29 entries (approximately
* 500 million). The maximum capacity is 2^30, but performance will degrade
* rapidly as 2^30 is approached.
@@ -33,20 +33,20 @@ extends AbstractMap[Long, V]
import LongMap._
def this() = this(LongMap.exceptionDefault, 16, true)
-
+
/** Creates a new `LongMap` that returns default values according to a supplied key-value mapping. */
def this(defaultEntry: Long => V) = this(defaultEntry, 16, true)
-
+
/** Creates a new `LongMap` with an initial buffer of specified size.
- *
+ *
* A LongMap can typically contain half as many elements as its buffer size
* before it requires resizing.
*/
def this(initialBufferSize: Int) = this(LongMap.exceptionDefault, initialBufferSize, true)
-
+
/** Creates a new `LongMap` with specified default values and initial buffer size. */
def this(defaultEntry: Long => V, initialBufferSize: Int) = this(defaultEntry, initialBufferSize, true)
-
+
private[this] var mask = 0
private[this] var extraKeys: Int = 0
private[this] var zeroValue: AnyRef = null
@@ -55,43 +55,43 @@ extends AbstractMap[Long, V]
private[this] var _vacant = 0
private[this] var _keys: Array[Long] = null
private[this] var _values: Array[AnyRef] = null
-
+
if (initBlank) defaultInitialize(initialBufferSize)
-
+
private[this] def defaultInitialize(n: Int) = {
- mask =
+ mask =
if (n<0) 0x7
else (((1 << (32 - java.lang.Integer.numberOfLeadingZeros(n-1))) - 1) & 0x3FFFFFFF) | 0x7
_keys = new Array[Long](mask+1)
_values = new Array[AnyRef](mask+1)
}
-
+
private[collection] def initializeTo(
m: Int, ek: Int, zv: AnyRef, mv: AnyRef, sz: Int, vc: Int, kz: Array[Long], vz: Array[AnyRef]
) {
mask = m; extraKeys = ek; zeroValue = zv; minValue = mv; _size = sz; _vacant = vc; _keys = kz; _values = vz
}
-
+
override def size: Int = _size + (extraKeys+1)/2
override def empty: LongMap[V] = new LongMap()
-
- private def imbalanced: Boolean =
+
+ private def imbalanced: Boolean =
(_size + _vacant) > 0.5*mask || _vacant > _size
-
+
private def toIndex(k: Long): Int = {
// Part of the MurmurHash3 32 bit finalizer
val h = ((k ^ (k >>> 32)) & 0xFFFFFFFFL).toInt
val x = (h ^ (h >>> 16)) * 0x85EBCA6B
(x ^ (x >>> 13)) & mask
}
-
+
private def seekEmpty(k: Long): Int = {
var e = toIndex(k)
var x = 0
while (_keys(e) != 0) { x += 1; e = (e + 2*(x+1)*x - 3) & mask }
e
}
-
+
private def seekEntry(k: Long): Int = {
var e = toIndex(k)
var x = 0
@@ -99,7 +99,7 @@ extends AbstractMap[Long, V]
while ({ q = _keys(e); if (q==k) return e; q != 0}) { x += 1; e = (e + 2*(x+1)*x - 3) & mask }
e | MissingBit
}
-
+
private def seekEntryOrOpen(k: Long): Int = {
var e = toIndex(k)
var x = 0
@@ -116,12 +116,12 @@ extends AbstractMap[Long, V]
}
o
}
-
+
override def contains(key: Long): Boolean = {
if (key == -key) (((key>>>63).toInt+1) & extraKeys) != 0
else seekEntry(key) >= 0
}
-
+
override def get(key: Long): Option[V] = {
if (key == -key) {
if ((((key>>>63).toInt+1) & extraKeys) == 0) None
@@ -133,7 +133,7 @@ extends AbstractMap[Long, V]
if (i < 0) None else Some(_values(i).asInstanceOf[V])
}
}
-
+
override def getOrElse[V1 >: V](key: Long, default: => V1): V1 = {
if (key == -key) {
if ((((key>>>63).toInt+1) & extraKeys) == 0) default
@@ -145,7 +145,7 @@ extends AbstractMap[Long, V]
if (i < 0) default else _values(i).asInstanceOf[V1]
}
}
-
+
override def getOrElseUpdate(key: Long, defaultValue: => V): V = {
if (key == -key) {
val kbits = (key>>>63).toInt + 1
@@ -185,10 +185,10 @@ extends AbstractMap[Long, V]
else _values(i).asInstanceOf[V]
}
}
-
+
/** Retrieves the value associated with a key, or the default for that type if none exists
* (null for AnyRef, 0 for floats and integers).
- *
+ *
* Note: this is the fastest way to retrieve a value that may or
* may not exist, if the default null/zero is acceptable. For key/value
* pairs that do exist, `apply` (i.e. `map(key)`) is equally fast.
@@ -204,8 +204,8 @@ extends AbstractMap[Long, V]
if (i < 0) null.asInstanceOf[V] else _values(i).asInstanceOf[V]
}
}
-
- /** Retrieves the value associated with a key.
+
+ /** Retrieves the value associated with a key.
* If the key does not exist in the map, the `defaultEntry` for that key
* will be returned instead.
*/
@@ -220,12 +220,12 @@ extends AbstractMap[Long, V]
if (i < 0) defaultEntry(key) else _values(i).asInstanceOf[V]
}
}
-
+
/** The user-supplied default value for the key. Throws an exception
* if no other default behavior was specified.
*/
override def default(key: Long) = defaultEntry(key)
-
+
private def repack(newMask: Int) {
val ok = _keys
val ov = _values
@@ -244,9 +244,9 @@ extends AbstractMap[Long, V]
i += 1
}
}
-
+
/** Repacks the contents of this `LongMap` for maximum efficiency of lookup.
- *
+ *
* For maps that undergo a complex creation process with both addition and
* removal of keys, and then are used heavily with no further removal of
* elements, calling `repack` after the end of the creation can result in
@@ -259,7 +259,7 @@ extends AbstractMap[Long, V]
while (m > 8 && 8*_size < m) m = m >>> 1
repack(m)
}
-
+
override def put(key: Long, value: V): Option[V] = {
if (key == -key) {
if (key == 0) {
@@ -294,9 +294,9 @@ extends AbstractMap[Long, V]
}
}
}
-
+
/** Updates the map to include a new key-value pair.
- *
+ *
* This is the fastest way to add an entry to a `LongMap`.
*/
override def update(key: Long, value: V): Unit = {
@@ -326,12 +326,12 @@ extends AbstractMap[Long, V]
}
}
}
-
+
/** Adds a new key/value pair to this map and returns the map. */
def +=(key: Long, value: V): this.type = { update(key, value); this }
-
+
def +=(kv: (Long, V)): this.type = { update(kv._1, kv._2); this }
-
+
def -=(key: Long): this.type = {
if (key == -key) {
if (key == 0L) {
@@ -354,22 +354,22 @@ extends AbstractMap[Long, V]
}
this
}
-
+
def iterator: Iterator[(Long, V)] = new Iterator[(Long, V)] {
private[this] val kz = _keys
private[this] val vz = _values
-
- private[this] var nextPair: (Long, V) =
+
+ private[this] var nextPair: (Long, V) =
if (extraKeys==0) null
else if ((extraKeys&1)==1) (0L, zeroValue.asInstanceOf[V])
else (Long.MinValue, minValue.asInstanceOf[V])
- private[this] var anotherPair: (Long, V) =
+ private[this] var anotherPair: (Long, V) =
if (extraKeys==3) (Long.MinValue, minValue.asInstanceOf[V])
else null
-
+
private[this] var index = 0
-
+
def hasNext: Boolean = nextPair != null || (index < kz.length && {
var q = kz(index)
while (q == -q) {
@@ -392,8 +392,8 @@ extends AbstractMap[Long, V]
ans
}
}
-
- override def foreach[A](f: ((Long,V)) => A) {
+
+ override def foreach[U](f: ((Long,V)) => U) {
if ((extraKeys & 1) == 1) f((0L, zeroValue.asInstanceOf[V]))
if ((extraKeys & 2) == 2) f((Long.MinValue, minValue.asInstanceOf[V]))
var i,j = 0
@@ -406,7 +406,7 @@ extends AbstractMap[Long, V]
i += 1
}
}
-
+
override def clone(): LongMap[V] = {
val kz = java.util.Arrays.copyOf(_keys, _keys.length)
val vz = java.util.Arrays.copyOf(_values, _values.length)
@@ -414,7 +414,7 @@ extends AbstractMap[Long, V]
lm.initializeTo(mask, extraKeys, zeroValue, minValue, _size, _vacant, kz, vz)
lm
}
-
+
/** Applies a function to all keys of this map. */
def foreachKey[A](f: Long => A) {
if ((extraKeys & 1) == 1) f(0L)
@@ -444,7 +444,7 @@ extends AbstractMap[Long, V]
i += 1
}
}
-
+
/** Creates a new `LongMap` with different values.
* Unlike `mapValues`, this method generates a new
* collection immediately.
@@ -467,8 +467,8 @@ extends AbstractMap[Long, V]
lm.initializeTo(mask, extraKeys, zv, mv, _size, _vacant, kz, vz)
lm
}
-
- /** Applies a transformation function to all values stored in this map.
+
+ /** Applies a transformation function to all values stored in this map.
* Note: the default, if any, is not transformed.
*/
def transformValues(f: V => V): this.type = {
@@ -492,15 +492,15 @@ object LongMap {
private final val MissingBit = 0x80000000
private final val VacantBit = 0x40000000
private final val MissVacant = 0xC0000000
-
+
private val exceptionDefault: Long => Nothing = (k: Long) => throw new NoSuchElementException(k.toString)
-
- implicit def canBuildFrom[V, U]: CanBuildFrom[LongMap[V], (Long, U), LongMap[U]] =
+
+ implicit def canBuildFrom[V, U]: CanBuildFrom[LongMap[V], (Long, U), LongMap[U]] =
new CanBuildFrom[LongMap[V], (Long, U), LongMap[U]] {
def apply(from: LongMap[V]): LongMapBuilder[U] = apply()
def apply(): LongMapBuilder[U] = new LongMapBuilder[U]
}
-
+
final class LongMapBuilder[V] extends Builder[(Long, V), LongMap[V]] {
private[collection] var elems: LongMap[V] = new LongMap[V]
def +=(entry: (Long, V)): this.type = {
@@ -519,14 +519,14 @@ object LongMap {
if (lm.size < (sz>>3)) lm.repack()
lm
}
-
+
/** Creates a new empty `LongMap`. */
def empty[V]: LongMap[V] = new LongMap[V]
-
+
/** Creates a new empty `LongMap` with the supplied default */
def withDefault[V](default: Long => V): LongMap[V] = new LongMap[V](default)
-
- /** Creates a new `LongMap` from arrays of keys and values.
+
+ /** Creates a new `LongMap` from arrays of keys and values.
* Equivalent to but more efficient than `LongMap((keys zip values): _*)`.
*/
def fromZip[V](keys: Array[Long], values: Array[V]): LongMap[V] = {
@@ -537,8 +537,8 @@ object LongMap {
if (lm.size < (sz>>3)) lm.repack()
lm
}
-
- /** Creates a new `LongMap` from keys and values.
+
+ /** Creates a new `LongMap` from keys and values.
* Equivalent to but more efficient than `LongMap((keys zip values): _*)`.
*/
def fromZip[V](keys: Iterable[Long], values: Iterable[V]): LongMap[V] = {
diff --git a/src/library/scala/collection/mutable/OpenHashMap.scala b/src/library/scala/collection/mutable/OpenHashMap.scala
index 24f5761cf5..5f8f5b9a0a 100644
--- a/src/library/scala/collection/mutable/OpenHashMap.scala
+++ b/src/library/scala/collection/mutable/OpenHashMap.scala
@@ -81,6 +81,9 @@ extends AbstractMap[Key, Value]
h ^ (h >>> 7) ^ (h >>> 4)
}
+ /** Increase the size of the table.
+ * Copy only the occupied slots, effectively eliminating the deleted slots.
+ */
private[this] def growTable() = {
val oldSize = mask + 1
val newSize = 4 * oldSize
@@ -92,8 +95,18 @@ extends AbstractMap[Key, Value]
deleted = 0
}
+ /** Return the index of the first slot in the hash table (in probe order)
+ * that either is empty, or is or was last occupied by the given key.
+ */
private[this] def findIndex(key: Key) : Int = findIndex(key, hashOf(key))
+ /** Return the index of the first slot in the hash table (in probe order)
+ * that either is empty, or is or was last occupied by the given key.
+ *
+ * This method is an optimization for when the hash value is in hand.
+ *
+ * @param hash hash value for `key`
+ */
private[this] def findIndex(key: Key, hash: Int): Int = {
var j = hash
@@ -136,7 +149,11 @@ extends AbstractMap[Key, Value]
None
} else {
val res = entry.value
- if (entry.value == None) { size += 1; modCount += 1 }
+ if (entry.value == None) {
+ size += 1
+ deleted -= 1
+ modCount += 1
+ }
entry.value = Some(value)
res
}
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/mutable/SynchronizedSet.scala b/src/library/scala/collection/mutable/SynchronizedSet.scala
index 60e2e79d3f..dd842f26ce 100644
--- a/src/library/scala/collection/mutable/SynchronizedSet.scala
+++ b/src/library/scala/collection/mutable/SynchronizedSet.scala
@@ -78,7 +78,7 @@ trait SynchronizedSet[A] extends Set[A] {
super.subsetOf(that)
}
- override def foreach[U](f: A => U) = synchronized {
+ override def foreach[U](f: A => U) = synchronized {
super.foreach(f)
}
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 016255dca4..8c9b959569 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -520,22 +520,22 @@ self: ParIterableLike[T, Repr, Sequential] =>
*
* $abortsignalling
*
- * @param pred a predicate used to test elements
+ * @param p a predicate used to test elements
* @return true if `p` holds for all elements, false otherwise
*/
- def forall(pred: T => Boolean): Boolean = {
- tasksupport.executeAndWaitResult(new Forall(pred, splitter assign new DefaultSignalling with VolatileAbort))
+ def forall(@deprecatedName('pred) p: T => Boolean): Boolean = {
+ tasksupport.executeAndWaitResult(new Forall(p, splitter assign new DefaultSignalling with VolatileAbort))
}
/** Tests whether a predicate holds for some element of this $coll.
*
* $abortsignalling
*
- * @param pred a predicate used to test elements
+ * @param p a predicate used to test elements
* @return true if `p` holds for some element, false otherwise
*/
- def exists(pred: T => Boolean): Boolean = {
- tasksupport.executeAndWaitResult(new Exists(pred, splitter assign new DefaultSignalling with VolatileAbort))
+ def exists(@deprecatedName('pred) p: T => Boolean): Boolean = {
+ tasksupport.executeAndWaitResult(new Exists(p, splitter assign new DefaultSignalling with VolatileAbort))
}
/** Finds some element in the collection for which the predicate holds, if such
@@ -546,11 +546,11 @@ self: ParIterableLike[T, Repr, Sequential] =>
*
* $abortsignalling
*
- * @param pred predicate used to test the elements
+ * @param p predicate used to test the elements
* @return an option value with the element if such an element exists, or `None` otherwise
*/
- def find(pred: T => Boolean): Option[T] = {
- tasksupport.executeAndWaitResult(new Find(pred, splitter assign new DefaultSignalling with VolatileAbort))
+ def find(@deprecatedName('pred) p: T => Boolean): Option[T] = {
+ tasksupport.executeAndWaitResult(new Find(p, splitter assign new DefaultSignalling with VolatileAbort))
}
/** Creates a combiner factory. Each combiner factory instance is used
@@ -1499,5 +1499,4 @@ self: ParIterableLike[T, Repr, Sequential] =>
append(s)
}
})
-
}
diff --git a/src/library/scala/collection/parallel/ParMapLike.scala b/src/library/scala/collection/parallel/ParMapLike.scala
index ee1334ba55..0a671fb085 100644
--- a/src/library/scala/collection/parallel/ParMapLike.scala
+++ b/src/library/scala/collection/parallel/ParMapLike.scala
@@ -99,14 +99,14 @@ self =>
def - (elem: K): ParSet[K] =
(ParSet[K]() ++ this - elem).asInstanceOf[ParSet[K]] // !!! concrete overrides abstract problem
override def size = self.size
- override def foreach[S](f: K => S) = for ((k, v) <- self) f(k)
+ override def foreach[U](f: K => U) = for ((k, v) <- self) f(k)
override def seq = self.seq.keySet
}
protected class DefaultValuesIterable extends ParIterable[V] {
def splitter = valuesIterator(self.splitter)
override def size = self.size
- override def foreach[S](f: V => S) = for ((k, v) <- self) f(v)
+ override def foreach[U](f: V => U) = for ((k, v) <- self) f(v)
def seq = self.seq.values
}
@@ -118,7 +118,7 @@ self =>
def filterKeys(p: K => Boolean): ParMap[K, V] = new ParMap[K, V] {
lazy val filtered = self.filter(kv => p(kv._1))
- override def foreach[S](f: ((K, V)) => S): Unit = for (kv <- self) if (p(kv._1)) f(kv)
+ override def foreach[U](f: ((K, V)) => U): Unit = for (kv <- self) if (p(kv._1)) f(kv)
def splitter = filtered.splitter
override def contains(key: K) = self.contains(key) && p(key)
def get(key: K) = if (!p(key)) None else self.get(key)
@@ -129,7 +129,7 @@ self =>
}
def mapValues[S](f: V => S): ParMap[K, S] = new ParMap[K, S] {
- override def foreach[Q](g: ((K, S)) => Q): Unit = for ((k, v) <- self) g((k, f(v)))
+ override def foreach[U](g: ((K, S)) => U): Unit = for ((k, v) <- self) g((k, f(v)))
def splitter = self.splitter.map(kv => (kv._1, f(kv._2)))
override def size = self.size
override def contains(key: K) = self.contains(key)
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala
index 294ca2aa48..ebc1e76ca1 100644
--- a/src/library/scala/concurrent/Future.scala
+++ b/src/library/scala/concurrent/Future.scala
@@ -43,6 +43,8 @@ import scala.reflect.ClassTag
*
* @author Philipp Haller, Heather Miller, Aleksandar Prokopec, Viktor Klang
*
+ * @see [[http://docs.scala-lang.org/overviews/core/futures.html Futures and Promises]]
+ *
* @define multipleCallbacks
* Multiple callbacks may be registered; there is no guarantee that they will be
* executed in a particular order.
diff --git a/src/library/scala/concurrent/duration/Duration.scala b/src/library/scala/concurrent/duration/Duration.scala
index 182c2d172a..e68a897f82 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 58ece8a05b..a75979385c 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/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala
index 4ff49c44d0..e099853463 100644
--- a/src/library/scala/reflect/Manifest.scala
+++ b/src/library/scala/reflect/Manifest.scala
@@ -157,6 +157,9 @@ object ManifestFactory {
override def newArray(len: Int): Array[Unit] = new Array[Unit](len)
override def newWrappedArray(len: Int): WrappedArray[Unit] = new WrappedArray.ofUnit(new Array[Unit](len))
override def newArrayBuilder(): ArrayBuilder[Unit] = new ArrayBuilder.ofUnit()
+ override protected def arrayClass[T](tp: Class[_]): Class[Array[T]] =
+ if (tp eq runtimeClass) classOf[Array[scala.runtime.BoxedUnit]].asInstanceOf[Class[Array[T]]]
+ else super.arrayClass(tp)
private def readResolve(): Any = Manifest.Unit
}
diff --git a/src/library/scala/reflect/ScalaLongSignature.java b/src/library/scala/reflect/ScalaLongSignature.java
index 5b6d78f446..94cf504aa4 100644
--- a/src/library/scala/reflect/ScalaLongSignature.java
+++ b/src/library/scala/reflect/ScalaLongSignature.java
@@ -8,5 +8,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ScalaLongSignature {
- public String[] bytes();
+ String[] bytes();
}
diff --git a/src/library/scala/reflect/ScalaSignature.java b/src/library/scala/reflect/ScalaSignature.java
index a8af554d2b..217ae8e8f7 100644
--- a/src/library/scala/reflect/ScalaSignature.java
+++ b/src/library/scala/reflect/ScalaSignature.java
@@ -8,5 +8,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ScalaSignature {
- public String bytes();
+ String bytes();
}
diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala
index 512c4fbc27..4109f5cb4b 100644
--- a/src/library/scala/runtime/Tuple2Zipped.scala
+++ b/src/library/scala/runtime/Tuple2Zipped.scala
@@ -84,12 +84,12 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
(b1.result(), b2.result())
}
- def exists(f: (El1, El2) => Boolean): Boolean = {
+ def exists(@deprecatedName('f) p: (El1, El2) => Boolean): Boolean = {
val elems2 = colls._2.iterator
for (el1 <- colls._1) {
if (elems2.hasNext) {
- if (f(el1, elems2.next()))
+ if (p(el1, elems2.next()))
return true
}
else return false
@@ -97,8 +97,8 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
false
}
- def forall(f: (El1, El2) => Boolean): Boolean =
- !exists((x, y) => !f(x, y))
+ def forall(@deprecatedName('f) p: (El1, El2) => Boolean): Boolean =
+ !exists((x, y) => !p(x, y))
def foreach[U](f: (El1, El2) => U): Unit = {
val elems2 = colls._2.iterator
diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala
index ffd44acf81..cde7699d40 100644
--- a/src/library/scala/runtime/Tuple3Zipped.scala
+++ b/src/library/scala/runtime/Tuple3Zipped.scala
@@ -90,13 +90,13 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
result
}
- def exists(f: (El1, El2, El3) => Boolean): Boolean = {
+ def exists(@deprecatedName('f) p: (El1, El2, El3) => Boolean): Boolean = {
val elems2 = colls._2.iterator
val elems3 = colls._3.iterator
for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext) {
- if (f(el1, elems2.next(), elems3.next()))
+ if (p(el1, elems2.next(), elems3.next()))
return true
}
else return false
@@ -104,8 +104,8 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
false
}
- def forall(f: (El1, El2, El3) => Boolean): Boolean =
- !exists((x, y, z) => !f(x, y, z))
+ def forall(@deprecatedName('f) p: (El1, El2, El3) => Boolean): Boolean =
+ !exists((x, y, z) => !p(x, y, z))
def foreach[U](f: (El1, El2, El3) => U): Unit = {
val elems2 = colls._2.iterator
diff --git a/src/library/scala/util/Either.scala b/src/library/scala/util/Either.scala
index e196d403c2..32b7ec4487 100644
--- a/src/library/scala/util/Either.scala
+++ b/src/library/scala/util/Either.scala
@@ -329,8 +329,8 @@ object Either {
* }}}
*
*/
- def forall(f: A => Boolean) = e match {
- case Left(a) => f(a)
+ def forall(@deprecatedName('f) p: A => Boolean) = e match {
+ case Left(a) => p(a)
case Right(_) => true
}
@@ -345,8 +345,8 @@ object Either {
* }}}
*
*/
- def exists(f: A => Boolean) = e match {
- case Left(a) => f(a)
+ def exists(@deprecatedName('f) p: A => Boolean) = e match {
+ case Left(a) => p(a)
case Right(_) => false
}
@@ -507,9 +507,9 @@ object Either {
* Left(12).right.exists(_ > 10) // false
* }}}
*/
- def exists(f: B => Boolean) = e match {
+ def exists(@deprecatedName('f) p: B => Boolean) = e match {
case Left(_) => false
- case Right(b) => f(b)
+ case Right(b) => p(b)
}
/**
diff --git a/src/library/scala/util/MurmurHash.scala b/src/library/scala/util/MurmurHash.scala
index e05fe0875b..1b6db5d6aa 100644
--- a/src/library/scala/util/MurmurHash.scala
+++ b/src/library/scala/util/MurmurHash.scala
@@ -10,7 +10,7 @@ package scala
package util
/** An implementation of Austin Appleby's MurmurHash 3.0 algorithm
- * (32 bit version); reference: http://code.google.com/p/smhasher
+ * (32 bit version); reference: https://github.com/aappleby/smhasher
*
* This is the hash used by collections and case classes (including
* tuples).
diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala
index d4a5e2f0e8..7ea597eac9 100644
--- a/src/library/scala/util/Properties.scala
+++ b/src/library/scala/util/Properties.scala
@@ -105,7 +105,7 @@ private[scala] trait PropertiesTrait {
* or "version (unknown)" if it cannot be determined.
*/
val versionString = "version " + scalaPropOrElse("version.number", "(unknown)")
- val copyrightString = scalaPropOrElse("copyright.string", "Copyright 2002-2015, LAMP/EPFL")
+ val copyrightString = scalaPropOrElse("copyright.string", "Copyright 2002-2016, LAMP/EPFL")
/** This is the encoding to use reading in source files, overridden with -encoding.
* Note that it uses "prop" i.e. looks in the scala jar, not the system properties.
diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala
index 4e5537954f..6a56910451 100644
--- a/src/library/scala/util/hashing/MurmurHash3.scala
+++ b/src/library/scala/util/hashing/MurmurHash3.scala
@@ -193,7 +193,7 @@ private[hashing] class MurmurHash3 {
* to remedy some weaknesses and improve performance. This represents the
* latest and supposedly final version of the algorithm (revision 136).
*
- * @see [[http://code.google.com/p/smhasher]]
+ * @see [[https://github.com/aappleby/smhasher]]
*/
object MurmurHash3 extends MurmurHash3 {
final val arraySeed = 0x3c074a61
diff --git a/src/manual/scala/man1/fsc.scala b/src/manual/scala/man1/fsc.scala
index f2f8feb3fa..c7399da635 100644
--- a/src/manual/scala/man1/fsc.scala
+++ b/src/manual/scala/man1/fsc.scala
@@ -126,11 +126,7 @@ object fsc extends Command {
"With Java 1.5 (or newer) one may for example configure the " &
"memory usage of the JVM as follows: " &
- Mono("JAVA_OPTS=\"-Xmx512M -Xms16M -Xss16M\""),
-
- "With " & Link("GNU Java", "http://gcc.gnu.org/java/") & " one " &
- "may configure the memory usage of the GIJ as follows: " &
- Mono("JAVA_OPTS=\"--mx512m --ms16m\"")
+ Mono("JAVA_OPTS=\"-Xmx512M -Xms16M -Xss16M\"")
))))
val exitStatus = Section("EXIT STATUS",
diff --git a/src/manual/scala/man1/scala.scala b/src/manual/scala/man1/scala.scala
index 92d9c59cca..9f97dd546c 100644
--- a/src/manual/scala/man1/scala.scala
+++ b/src/manual/scala/man1/scala.scala
@@ -65,6 +65,10 @@ object scala extends Command {
"Do not use the " & MBold("fsc") & " offline compiler."),
Definition(
+ CmdOption("nc"),
+ "Same as " & Mono("-nocompdaemon") & "."),
+
+ Definition(
CmdOptionBound("D", "property=value"),
"Set a Java system property. If no value is specified, " &
"then the property is set to the empty string."),
@@ -135,6 +139,11 @@ object scala extends Command {
"line. Headers can be used to make stand-alone script files, as shown " &
"in the examples below.",
+ "When running a script or using " & Mono("-e") & ", an already running " &
+ "compilation daemon (fsc) is used, or a new one started on demand. The " &
+ Mono("-nocompdaemon") & " or " & Mono("-nc") & " option can be used to " &
+ "prevent this.",
+
"If " & Mono("scala") & " is run from an sbaz(1) directory, " &
"then it will add to its classpath any jars installed in the " &
"lib directory of the sbaz directory. Additionally, if no " &
@@ -175,11 +184,7 @@ object scala extends Command {
"With Java 1.5 (or newer) one may for example configure the " &
"memory usage of the JVM as follows: " &
- Mono("JAVA_OPTS=\"-Xmx512M -Xms16M -Xss16M\""),
-
- "With " & Link("GNU Java", "http://gcc.gnu.org/java/") & " one " &
- "may configure the memory usage of the GIJ as follows: " &
- Mono("JAVA_OPTS=\"--mx512m --ms16m\"")
+ Mono("JAVA_OPTS=\"-Xmx512M -Xms16M -Xss16M\"")
))))
val examples = Section("EXAMPLES",
diff --git a/src/manual/scala/man1/scalac.scala b/src/manual/scala/man1/scalac.scala
index c658fe89f8..7e8277f5ad 100644
--- a/src/manual/scala/man1/scalac.scala
+++ b/src/manual/scala/man1/scalac.scala
@@ -450,11 +450,7 @@ object scalac extends Command {
"With Java 1.5 (or newer) one may for example configure the " &
"memory usage of the JVM as follows: " &
- Mono("JAVA_OPTS=\"-Xmx512M -Xms16M -Xss16M\""),
-
- "With " & Link("GNU Java", "http://gcc.gnu.org/java/") & " one " &
- "may configure the memory usage of the GIJ as follows: " &
- Mono("JAVA_OPTS=\"--mx512m --ms16m\"")
+ Mono("JAVA_OPTS=\"-Xmx512M -Xms16M -Xss16M\"")
))))
val examples = Section("EXAMPLES",
diff --git a/src/manual/scala/tools/docutil/ManMaker.scala b/src/manual/scala/tools/docutil/ManMaker.scala
index 802b357f5f..4b8bfc6606 100644
--- a/src/manual/scala/tools/docutil/ManMaker.scala
+++ b/src/manual/scala/tools/docutil/ManMaker.scala
@@ -57,3 +57,13 @@ class ManMaker extends Task {
})
}
}
+
+/** Command line runner for ManMaker which is called from the sbt build. */
+object ManMaker extends App {
+ val Array(commands, htmlout, manout) = args
+ val mm = new ManMaker
+ mm.setCommand(commands)
+ mm.setHtmlout(new File(htmlout))
+ mm.setManout(new File(manout))
+ mm.execute()
+}
diff --git a/src/reflect/scala/reflect/api/Internals.scala b/src/reflect/scala/reflect/api/Internals.scala
index 1457fdc133..f57d7efa00 100644
--- a/src/reflect/scala/reflect/api/Internals.scala
+++ b/src/reflect/scala/reflect/api/Internals.scala
@@ -939,7 +939,7 @@ trait Internals { self: Universe =>
/** Marks underlying reference to id as boxed.
*
- * <b>Precondition:<\b> id must refer to a captured variable
+ * <b>Precondition:</b> id must refer to a captured variable
* A reference such marked will refer to the boxed entity, no dereferencing
* with `.elem` is done on it.
* This tree node can be emitted by macros such as reify that call referenceCapturedVariable.
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index 4bdb8e6da8..3b9ee9048a 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.
*/
@@ -500,7 +500,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) {
@@ -1256,8 +1256,9 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** These should be moved somewhere like JavaPlatform.
*/
def javaSimpleName: Name = addModuleSuffix(simpleName.dropLocal)
- def javaBinaryName: Name = addModuleSuffix(fullNameInternal('/'))
- def javaClassName: String = addModuleSuffix(fullNameInternal('.')).toString
+ def javaBinaryName: Name = name.newName(javaBinaryNameString)
+ def javaBinaryNameString: String = fullName('/', moduleSuffix)
+ def javaClassName: String = fullName('.', moduleSuffix)
/** The encoded full path name of this symbol, where outer names and inner names
* are separated by `separator` characters.
@@ -1265,18 +1266,29 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
* Never adds id.
* Drops package objects.
*/
- final def fullName(separator: Char): String = fullNameAsName(separator).toString
-
- /** Doesn't drop package objects, for those situations (e.g. classloading)
- * where the true path is needed.
- */
- private def fullNameInternal(separator: Char): Name = (
- if (isRoot || isRootPackage || this == NoSymbol) name
- else if (owner.isEffectiveRoot) name
- else effectiveOwner.enclClass.fullNameAsName(separator) append (separator, name)
- )
+ final def fullName(separator: Char): String = fullName(separator, "")
+
+ private def fullName(separator: Char, suffix: CharSequence): String = {
+ var b: java.lang.StringBuffer = null
+ def loop(size: Int, sym: Symbol): Unit = {
+ val symName = sym.name
+ val nSize = symName.length - (if (symName.endsWith(nme.LOCAL_SUFFIX_STRING)) 1 else 0)
+ if (sym.isRoot || sym.isRootPackage || sym == NoSymbol || sym.owner.isEffectiveRoot) {
+ val capacity = size + nSize
+ b = new java.lang.StringBuffer(capacity)
+ b.append(chrs, symName.start, nSize)
+ } else {
+ loop(size + nSize + 1, sym.effectiveOwner.enclClass)
+ b.append(separator)
+ b.append(chrs, symName.start, nSize)
+ }
+ }
+ loop(suffix.length(), this)
+ b.append(suffix)
+ b.toString
+ }
- def fullNameAsName(separator: Char): Name = fullNameInternal(separator).dropLocal
+ def fullNameAsName(separator: Char): Name = name.newName(fullName(separator, ""))
/** The encoded full path name of this symbol, where outer names and inner names
* are separated by periods.
diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala
index ef22df3f2e..af04f47e0e 100644
--- a/src/reflect/scala/reflect/internal/Variances.scala
+++ b/src/reflect/scala/reflect/internal/Variances.scala
@@ -122,15 +122,21 @@ trait Variances {
* same is true of the parameters (ValDefs) unless we are inside a
* refinement, in which case they are checked from here.
*/
- def apply(tp: Type): Type = tp match {
- case _ if isUncheckedVariance(tp) => tp
- case _ if resultTypeOnly(tp) => this(tp.resultType)
- case TypeRef(_, sym, _) if sym.isAliasType => this(tp.normalize)
- case TypeRef(_, sym, _) if !sym.variance.isInvariant => checkVarianceOfSymbol(sym) ; mapOver(tp)
- case RefinedType(_, _) => withinRefinement(mapOver(tp))
- case ClassInfoType(parents, _, _) => parents foreach this ; tp
- case mt @ MethodType(_, result) => flipped(mt.paramTypes foreach this) ; this(result)
- case _ => mapOver(tp)
+ def apply(tp: Type): Type = {
+ tp match {
+ case _ if isUncheckedVariance(tp) =>
+ case _ if resultTypeOnly(tp) => this(tp.resultType)
+ case TypeRef(_, sym, _) if sym.isAliasType => this(tp.normalize)
+ case TypeRef(_, sym, _) if !sym.variance.isInvariant => checkVarianceOfSymbol(sym) ; mapOver(tp)
+ case RefinedType(_, _) => withinRefinement(mapOver(tp))
+ case ClassInfoType(parents, _, _) => parents foreach this
+ case mt @ MethodType(_, result) => flipped(mt.paramTypes foreach this) ; this(result)
+ case _ => mapOver(tp)
+ }
+ // We're using TypeMap here for type traversal only. To avoid wasteful symbol
+ // cloning during the recursion, it is important to return the input `tp`, rather
+ // than the result of the pattern match above, which normalizes types.
+ tp
}
def validateDefinition(base: Symbol) {
val saved = this.base
diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
index b8d4050d7d..804360b677 100644
--- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
+++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala
@@ -998,10 +998,20 @@ private[internal] trait TypeMaps {
class ContainsCollector(sym: Symbol) extends TypeCollector(false) {
def traverse(tp: Type) {
if (!result) {
- tp.normalize match {
- case TypeRef(_, sym1, _) if (sym == sym1) => result = true
- case SingleType(_, sym1) if (sym == sym1) => result = true
- case _ => mapOver(tp)
+ tp match {
+ case _: ExistentialType =>
+ // ExistentialType#normalize internally calls contains, which leads to exponential performance
+ // for types like: `A[_ <: B[_ <: ... ]]`. Example: pos/existential-contains.scala.
+ //
+ // We can just map over the components and wait until we see the underlying type before we call
+ // normalize.
+ mapOver(tp)
+ case _ =>
+ tp.normalize match {
+ case TypeRef(_, sym1, _) if (sym == sym1) => result = true
+ case SingleType(_, sym1) if (sym == sym1) => result = true
+ case _ => mapOver(tp)
+ }
}
}
}
diff --git a/src/reflect/scala/reflect/internal/util/WeakHashSet.scala b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala
index 3a7a7626fb..83d2a3453b 100644
--- a/src/reflect/scala/reflect/internal/util/WeakHashSet.scala
+++ b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala
@@ -41,7 +41,7 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D
* power of two equal to or greater than the specified initial capacity
*/
private def computeCapacity = {
- if (initialCapacity < 0) throw new IllegalArgumentException("initial capacity cannot be less than 0");
+ if (initialCapacity < 0) throw new IllegalArgumentException("initial capacity cannot be less than 0")
var candidate = 1
while (candidate < initialCapacity) {
candidate *= 2
@@ -372,13 +372,13 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D
* Number of buckets that hold collisions. Useful for diagnosing performance issues.
*/
def collisionBucketsCount: Int =
- (table filter (entry => entry != null && entry.tail != null)).size
+ (table count (entry => entry != null && entry.tail != null))
/**
* Number of buckets that are occupied in this hash table.
*/
def fullBucketsCount: Int =
- (table filter (entry => entry != null)).size
+ (table count (entry => entry != null))
/**
* Number of buckets in the table
diff --git a/src/reflect/scala/reflect/macros/Attachments.scala b/src/reflect/scala/reflect/macros/Attachments.scala
index b5c340645a..0b5360c004 100644
--- a/src/reflect/scala/reflect/macros/Attachments.scala
+++ b/src/reflect/scala/reflect/macros/Attachments.scala
@@ -39,7 +39,7 @@ abstract class Attachments { self =>
/** An underlying payload of the given class type `T`. */
def get[T: ClassTag]: Option[T] =
- (all filter matchesTag[T]).headOption.asInstanceOf[Option[T]]
+ (all find matchesTag[T]).asInstanceOf[Option[T]]
/** Check underlying payload contains an instance of type `T`. */
def contains[T: ClassTag]: Boolean =
diff --git a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala
index a4bd698068..a278ed3fd7 100644
--- a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala
+++ b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala
@@ -72,7 +72,7 @@ object ReflectionUtils {
def singletonAccessor(clazz: Class[_]): Option[Method] =
if (clazz == null) None
else {
- val declaredAccessor = clazz.getDeclaredMethods.filter(_.getName == accessorName).headOption
+ val declaredAccessor = clazz.getDeclaredMethods.find(_.getName == accessorName)
declaredAccessor orElse singletonAccessor(clazz.getSuperclass)
}
@@ -92,7 +92,7 @@ object ReflectionUtils {
}
class EnclosedIn[T](enclosure: jClass[_] => T) {
- def unapply(jclazz: jClass[_]): Option[T] = if (enclosure(jclazz) != null) Some(enclosure(jclazz)) else None
+ def unapply(jclazz: jClass[_]): Option[T] = Option(enclosure(jclazz))
}
object EnclosedInMethod extends EnclosedIn(_.getEnclosingMethod)
diff --git a/src/reflect/scala/reflect/runtime/SynchronizedOps.scala b/src/reflect/scala/reflect/runtime/SynchronizedOps.scala
index 4a8585d616..f0d96e0fd6 100644
--- a/src/reflect/scala/reflect/runtime/SynchronizedOps.scala
+++ b/src/reflect/scala/reflect/runtime/SynchronizedOps.scala
@@ -15,7 +15,7 @@ private[reflect] trait SynchronizedOps extends internal.SymbolTable
override protected def newBaseTypeSeq(parents: List[Type], elems: Array[Type]) =
// only need to synchronize BaseTypeSeqs if they contain refined types
- if (elems.filter(_.isInstanceOf[RefinedType]).nonEmpty) new BaseTypeSeq(parents, elems) with SynchronizedBaseTypeSeq
+ if (elems.exists(_.isInstanceOf[RefinedType])) new BaseTypeSeq(parents, elems) with SynchronizedBaseTypeSeq
else new BaseTypeSeq(parents, elems)
trait SynchronizedBaseTypeSeq extends BaseTypeSeq {
@@ -31,7 +31,7 @@ private[reflect] trait SynchronizedOps extends internal.SymbolTable
override def lateMap(f: Type => Type): BaseTypeSeq =
// only need to synchronize BaseTypeSeqs if they contain refined types
- if (map(f).toList.filter(_.isInstanceOf[RefinedType]).nonEmpty) new MappedBaseTypeSeq(this, f) with SynchronizedBaseTypeSeq
+ if (map(f).toList.exists(_.isInstanceOf[RefinedType])) new MappedBaseTypeSeq(this, f) with SynchronizedBaseTypeSeq
else new MappedBaseTypeSeq(this, f)
}
diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala
index f844029b64..adac438b37 100644
--- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala
+++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala
@@ -694,25 +694,37 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
Iterator continually in.readLine("") takeWhile (x => x != null && cond(x))
}
+ /* :paste -raw file
+ * or
+ * :paste < EOF
+ * your code
+ * EOF
+ * :paste <~ EOF
+ * ~your code
+ * EOF
+ */
def pasteCommand(arg: String): Result = {
var shouldReplay: Option[String] = None
def result = Result(keepRunning = true, shouldReplay)
- val (raw, file) =
- if (arg.isEmpty) (false, None)
+ val (raw, file, margin) =
+ if (arg.isEmpty) (false, None, None)
else {
- val r = """(-raw)?(\s+)?([^\-]\S*)?""".r
- arg match {
- case r(flag, sep, name) =>
- if (flag != null && name != null && sep == null)
- echo(s"""I assume you mean "$flag $name"?""")
- (flag != null, Option(name))
- case _ =>
- echo("usage: :paste -raw file")
- return result
+ def maybeRaw(ss: List[String]) = if (ss.nonEmpty && ss.head == "-raw") (true, ss.tail) else (false, ss)
+ def maybeHere(ss: List[String]) =
+ if (ss.nonEmpty && ss.head.startsWith("<")) (ss.head.dropWhile(_ == '<'), ss.tail)
+ else (null, ss)
+
+ val (raw0, ss0) = maybeRaw(words(arg))
+ val (margin0, ss1) = maybeHere(ss0)
+ val file0 = ss1 match {
+ case Nil => null
+ case x :: Nil => x
+ case _ => echo("usage: :paste [-raw] file | < EOF") ; return result
}
+ (raw0, Option(file0), Option(margin0))
}
- val code = file match {
- case Some(name) =>
+ val code = (file, margin) match {
+ case (Some(name), None) =>
withFile(name) { f =>
shouldReplay = Some(s":paste $arg")
val s = f.slurp.trim
@@ -720,9 +732,16 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
else echo(s"Pasting file $f...")
s
} getOrElse ""
- case None =>
- echo("// Entering paste mode (ctrl-D to finish)\n")
- val text = (readWhile(_ => true) mkString "\n").trim
+ case (eof, _) =>
+ echo(s"// Entering paste mode (${ eof getOrElse "ctrl-D" } to finish)\n")
+ val delimiter = eof orElse replProps.pasteDelimiter.option
+ val input = readWhile(s => delimiter.isEmpty || delimiter.get != s) mkString "\n"
+ val text = (
+ margin filter (_.nonEmpty) map {
+ case "-" => input.lines map (_.trim) mkString "\n"
+ case m => input stripMargin m.head // ignore excess chars in "<<||"
+ } getOrElse input
+ ).trim
if (text.isEmpty) echo("\n// Nothing pasted, nothing gained.\n")
else echo("\n// Exiting paste mode, now interpreting.\n")
text
@@ -857,7 +876,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
if (settings.debug) {
val readerDiags = (readerClasses, readers).zipped map {
- case (cls, Failure(e)) => s" - $cls --> " + e.getStackTrace.mkString(e.toString+"\n\t", "\n\t","\n")
+ case (cls, Failure(e)) => s" - $cls --> \n\t" + scala.tools.nsc.util.stackTraceString(e) + "\n"
case (cls, Success(_)) => s" - $cls OK"
}
Console.println(s"All InteractiveReaders tried: ${readerDiags.mkString("\n","\n","\n")}")
diff --git a/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala
index e9b0234a4f..c2ccfc8064 100644
--- a/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala
+++ b/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala
@@ -175,7 +175,7 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput
case Some((clazz, runtimeType)) =>
val sym = intp.symbolOfTerm(id)
if (sym.isStable) {
- val param = new NamedParam.Untyped(id, intp valueOfTerm id getOrElse null)
+ val param = new NamedParam.Untyped(id, intp valueOfTerm id orNull)
Some(TypeMemberCompletion(tpe, runtimeType, param))
}
else default
diff --git a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
index c240ab027a..9ad9479d05 100644
--- a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
+++ b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala
@@ -600,11 +600,11 @@ object JavapClass {
def parents: List[ClassLoader] = parentsOf(loader)
/* all file locations */
def locations = {
- def alldirs = parents flatMap (_ match {
+ def alldirs = parents flatMap {
case ucl: ScalaClassLoader.URLClassLoader => ucl.classPathURLs
case jcl: java.net.URLClassLoader => jcl.getURLs
case _ => Nil
- })
+ }
val dirs = for (d <- alldirs; if d.getProtocol == "file") yield Path(new JFile(d.toURI))
dirs
}
diff --git a/src/repl/scala/tools/nsc/interpreter/ReplProps.scala b/src/repl/scala/tools/nsc/interpreter/ReplProps.scala
index 588d92f81b..f3115d9800 100644
--- a/src/repl/scala/tools/nsc/interpreter/ReplProps.scala
+++ b/src/repl/scala/tools/nsc/interpreter/ReplProps.scala
@@ -64,6 +64,8 @@ class ReplProps {
if (p.isSet) p.get else shellWelcomeString
}
+ val pasteDelimiter = Prop[String]("scala.repl.here")
+
/** CSV of paged,across to enable pagination or `-x` style
* columns, "across" instead of down the column. Since
* pagination turns off columnar output, these flags are
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..9679a13e74 100644
--- a/src/scaladoc/scala/tools/nsc/doc/Settings.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/Settings.scala
@@ -25,7 +25,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_))
)
/** A setting that defines the overall title of the documentation, typically the name of the library being
- * documented. ''Note:'' This setting is currently not used. */
+ * documented. */
val doctitle = StringSetting (
"-doc-title",
"title",
@@ -34,7 +34,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_))
)
/** A setting that defines the overall version number of the documentation, typically the version of the library being
- * documented. ''Note:'' This setting is currently not used. */
+ * documented. */
val docversion = StringSetting (
"-doc-version",
"version",
@@ -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/Lightbend copyright notice. Can be overridden with a custom footer.",
""
)
@@ -212,9 +212,10 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_))
// For improved help output.
def scaladocSpecific = Set[Settings#Setting](
docformat, doctitle, docfooter, docversion, docUncompilable, docsourceurl, docgenerator, docRootContent, useStupidTypes,
+ docExternalDoc,
docAuthor, docDiagrams, docDiagramsDebug, docDiagramsDotPath,
docDiagramsDotTimeout, docDiagramsDotRestart,
- docImplicits, docImplicitsDebug, docImplicitsShowAll, docImplicitsHide,
+ docImplicits, docImplicitsDebug, docImplicitsShowAll, docImplicitsHide, docImplicitsSoundShadowing,
docDiagramsMaxNormalClasses, docDiagramsMaxImplicitClasses,
docNoPrefixes, docNoLinkWarnings, docRawOutput, docSkipPackages,
docExpandAllTypes, docGroups
@@ -275,24 +276,36 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_))
("scala.reflect.ClassManifest" -> ((tparam: String) => tparam + " is accompanied by a ClassManifest, which is a runtime representation of its type that survives erasure")) +
("scala.reflect.OptManifest" -> ((tparam: String) => tparam + " is accompanied by an OptManifest, which can be either a runtime representation of its type or the NoManifest, which means the runtime type is not available")) +
("scala.reflect.ClassTag" -> ((tparam: String) => tparam + " is accompanied by a ClassTag, which is a runtime representation of its type that survives erasure")) +
- ("scala.reflect.api.TypeTags.WeakTypeTag" -> ((tparam: String) => tparam + " is accompanied by an WeakTypeTag, which is a runtime representation of its type that survives erasure")) +
+ ("scala.reflect.api.TypeTags.WeakTypeTag" -> ((tparam: String) => tparam + " is accompanied by a WeakTypeTag, which is a runtime representation of its type that survives erasure")) +
("scala.reflect.api.TypeTags.TypeTag" -> ((tparam: String) => tparam + " is accompanied by a TypeTag, which is a runtime representation of its type that survives erasure"))
+ private val excludedClassnamePatterns = Set(
+ """^scala.Tuple.*""",
+ """^scala.Product.*""",
+ """^scala.Function.*""",
+ """^scala.runtime.AbstractFunction.*"""
+ ) map (_.r)
+
+ private val notExcludedClasses = Set(
+ "scala.Tuple1",
+ "scala.Tuple2",
+ "scala.Product",
+ "scala.Product1",
+ "scala.Product2",
+ "scala.Function",
+ "scala.Function1",
+ "scala.Function2",
+ "scala.runtime.AbstractFunction0",
+ "scala.runtime.AbstractFunction1",
+ "scala.runtime.AbstractFunction2"
+ )
+
/**
* Set of classes to exclude from index and diagrams
* TODO: Should be configurable
*/
def isExcluded(qname: String) = {
- ( ( qname.startsWith("scala.Tuple") || qname.startsWith("scala.Product") ||
- qname.startsWith("scala.Function") || qname.startsWith("scala.runtime.AbstractFunction")
- ) && !(
- qname == "scala.Tuple1" || qname == "scala.Tuple2" ||
- qname == "scala.Product" || qname == "scala.Product1" || qname == "scala.Product2" ||
- qname == "scala.Function" || qname == "scala.Function1" || qname == "scala.Function2" ||
- qname == "scala.runtime.AbstractFunction0" || qname == "scala.runtime.AbstractFunction1" ||
- qname == "scala.runtime.AbstractFunction2"
- )
- )
+ excludedClassnamePatterns.exists(_.findFirstMatchIn(qname).isDefined) && !notExcludedClasses(qname)
}
/** Common conversion targets that affect any class in Scala */
diff --git a/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala b/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
index fb4ed34571..f1c96636e2 100644
--- a/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
@@ -48,7 +48,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
groupNames0: Map[String,Body] = Map.empty,
groupPrio0: Map[String,Body] = Map.empty
) : Comment = new Comment{
- val body = if(body0 isDefined) body0.get else Body(Seq.empty)
+ val body = body0 getOrElse Body(Seq.empty)
val authors = authors0
val see = see0
val result = result0
@@ -83,13 +83,9 @@ trait CommentFactoryBase { this: MemberLookupBase =>
}
val groupNames = groupNames0 flatMap {
case (group, body) =>
- try {
- body match {
- case Body(List(Paragraph(Chain(List(Summary(Text(name))))))) if (!name.trim.contains("\n")) => List(group -> (name.trim))
- case _ => List()
- }
- } catch {
- case _: java.lang.NumberFormatException => List()
+ body match {
+ case Body(List(Paragraph(Chain(List(Summary(Text(name))))))) if (!name.trim.contains("\n")) => List(group -> (name.trim))
+ case _ => List()
}
}
@@ -165,11 +161,11 @@ trait CommentFactoryBase { this: MemberLookupBase =>
private val SymbolTagRegex =
new Regex("""\s*@(param|tparam|throws|groupdesc|groupname|groupprio)\s+(\S*)\s*(.*)""")
- /** The start of a scaladoc code block */
+ /** The start of a Scaladoc code block */
private val CodeBlockStartRegex =
new Regex("""(.*?)((?:\{\{\{)|(?:\u000E<pre(?: [^>]*)?>\u000E))(.*)""")
- /** The end of a scaladoc code block */
+ /** The end of a Scaladoc code block */
private val CodeBlockEndRegex =
new Regex("""(.*?)((?:\}\}\})|(?:\u000E</pre>\u000E))(.*)""")
@@ -183,6 +179,8 @@ trait CommentFactoryBase { this: MemberLookupBase =>
private final case class SimpleTagKey(name: String) extends TagKey
private final case class SymbolTagKey(name: String, symbol: String) extends TagKey
+ private val TrailingWhitespaceRegex = """\s+$""".r
+
/** Parses a raw comment string into a `Comment` object.
* @param comment The expanded comment string (including start and end markers) to be parsed.
* @param src The raw comment source string.
@@ -192,8 +190,8 @@ trait CommentFactoryBase { this: MemberLookupBase =>
* start and end markers, line start markers and unnecessary whitespace. */
def clean(comment: String): List[String] = {
def cleanLine(line: String): String = {
- //replaceAll removes trailing whitespaces
- line.replaceAll("""\s+$""", "") match {
+ // Remove trailing whitespaces
+ TrailingWhitespaceRegex.replaceAllIn(line, "") match {
case CleanCommentLine(ctl) => ctl
case tl => tl
}
@@ -321,7 +319,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
def oneTag(key: SimpleTagKey, filterEmpty: Boolean = true): Option[Body] =
((bodyTags remove key): @unchecked) match {
case Some(r :: rs) if !(filterEmpty && r.blocks.isEmpty) =>
- if (!rs.isEmpty) reporter.warning(pos, "Only one '@" + key.name + "' tag is allowed")
+ if (!rs.isEmpty) reporter.warning(pos, s"Only one '@${key.name}' tag is allowed")
Some(r)
case _ => None
}
@@ -334,7 +332,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
bodyTags.keys.toSeq flatMap {
case stk: SymbolTagKey if (stk.name == key.name) => Some(stk)
case stk: SimpleTagKey if (stk.name == key.name) =>
- reporter.warning(pos, "Tag '@" + stk.name + "' must be followed by a symbol name")
+ reporter.warning(pos, s"Tag '@${stk.name}' must be followed by a symbol name")
None
case _ => None
}
@@ -342,7 +340,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
for (key <- keys) yield {
val bs = (bodyTags remove key).get
if (bs.length > 1)
- reporter.warning(pos, "Only one '@" + key.name + "' tag for symbol " + key.symbol + " is allowed")
+ reporter.warning(pos, s"Only one '@${key.name}' tag for symbol ${key.symbol} is allowed")
(key.symbol, bs.head)
}
Map.empty[String, Body] ++ (if (filterEmpty) pairs.filterNot(_._2.blocks.isEmpty) else pairs)
@@ -389,7 +387,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
)
for ((key, _) <- bodyTags)
- reporter.warning(pos, "Tag '@" + key.name + "' is not recognised")
+ reporter.warning(pos, s"Tag '@${key.name}' is not recognised")
com
@@ -424,7 +422,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
/* BLOCKS */
- /** {{{ block ::= code | title | hrule | para }}} */
+ /** {{{ block ::= code | title | hrule | listBlock | para }}} */
def block(): Block = {
if (checkSkipInitWhitespace("{{{"))
code()
@@ -459,7 +457,7 @@ trait CommentFactoryBase { this: MemberLookupBase =>
* nLine ::= nSpc listStyle para '\n'
* }}}
* Where n and m stand for the number of spaces. When `m > n`, a new list is nested. */
- def listBlock: Block = {
+ def listBlock(): Block = {
/** Consumes one list item block and returns it, or None if the block is
* not a list or a different list. */
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 6b13a02c54..f70bac8f83 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala
@@ -139,7 +139,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>
@@ -175,7 +175,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>
}
@@ -280,7 +280,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp
{
if (Set("epfl", "EPFL").contains(tpl.universe.settings.docfooter.value))
- <div id="footer">Scala programming documentation. Copyright (c) 2003-2015 <a href="http://www.epfl.ch" target="_top">EPFL</a>, with contributions from <a href="http://typesafe.com" target="_top">Typesafe</a>.</div>
+ <div id="footer">Scala programming documentation. Copyright (c) 2003-2016 <a href="http://www.epfl.ch" target="_top">EPFL</a>, with contributions from <a href="http://www.lightbend.com" target="_top">Lightbend</a>.</div>
else
<div id="footer"> { tpl.universe.settings.docfooter.value } </div>
}
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala
index 9381cf3a35..9287bfbc2b 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala
+++ b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala
@@ -18,16 +18,16 @@ import model._
/** This class takes care of running the graphviz dot utility */
class DotRunner(settings: doc.Settings) {
- private[this] var dotRestarts = 0
+ private[this] var dotAttempts = 0
private[this] var dotProcess: DotProcess = null
def feedToDot(dotInput: String, template: DocTemplateEntity): String = {
if (dotProcess == null) {
- if (dotRestarts < settings.docDiagramsDotRestart.value) {
- if (dotRestarts != 0)
+ if (dotAttempts < settings.docDiagramsDotRestart.value + 1) {
+ if (dotAttempts > 0)
settings.printMsg("Graphviz will be restarted...\n")
- dotRestarts += 1
+ dotAttempts += 1
dotProcess = new DotProcess(settings)
} else
return null
@@ -41,7 +41,7 @@ class DotRunner(settings: doc.Settings) {
if (result == null) {
dotProcess.cleanup()
dotProcess = null
- if (dotRestarts == settings.docDiagramsDotRestart.value) {
+ if (dotAttempts == 1 + settings.docDiagramsDotRestart.value) {
settings.printMsg("\n")
settings.printMsg("**********************************************************************")
settings.printMsg("Diagrams will be disabled for this run because the graphviz dot tool")
diff --git a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/jquery.layout.js b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/jquery.layout.js
index 4dd48675b7..d5e008d289 100644
--- a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/jquery.layout.js
+++ b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/jquery.layout.js
@@ -752,7 +752,7 @@ $.layout.defaults = {
* PANE-SPECIFIC SETTINGS
* - options listed below MUST be specified per-pane - they CANNOT be set under 'panes'
* - all options under the 'panes' key can also be set specifically for any pane
- * - most options under the 'panes' key apply only to 'border-panes' - NOT the the center-pane
+ * - most options under the 'panes' key apply only to 'border-panes' - NOT the center-pane
*/
, north: {
paneSelector: ".ui-layout-north"
@@ -921,7 +921,7 @@ $.layout.backwardCompatibility = {
$.extend(true, opts.panes, opts.defaults);
delete opts.defaults;
}
- // rename options in the the options.panes key
+ // rename options in the options.panes key
if (opts.panes) ren( opts.panes );
// rename options inside *each pane key*, eg: options.west
$.each($.layout.config.allPanes, function (i, pane) {
@@ -5483,4 +5483,4 @@ $.layout.onReady.push( $.layout.browserZoom._init );
-})( jQuery ); \ No newline at end of file
+})( jQuery );
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)
diff --git a/src/scalap/decoder.properties b/src/scalap/decoder.properties
index 333f6ce715..9bb8d130ea 100644
--- a/src/scalap/decoder.properties
+++ b/src/scalap/decoder.properties
@@ -1,2 +1,2 @@
version.number=2.0.1
-copyright.string=(c) 2002-2015 LAMP/EPFL
+copyright.string=(c) 2002-2016 LAMP/EPFL
diff --git a/src/scalap/scala/tools/scalap/CodeWriter.scala b/src/scalap/scala/tools/scalap/CodeWriter.scala
index 168050096d..07aba0b632 100644
--- a/src/scalap/scala/tools/scalap/CodeWriter.scala
+++ b/src/scalap/scala/tools/scalap/CodeWriter.scala
@@ -35,7 +35,7 @@ class CodeWriter(writer: Writer) {
def setIndentWidth(width: Int): CodeWriter =
setIndentString(List.fill(width)(' ').mkString)
- def getIndentString = step;
+ def getIndentString = step
def setIndentString(step: String): CodeWriter = {
this.step = step
diff --git a/src/scalap/scala/tools/scalap/Decode.scala b/src/scalap/scala/tools/scalap/Decode.scala
index 76ce3f4173..310d6117e6 100644
--- a/src/scalap/scala/tools/scalap/Decode.scala
+++ b/src/scalap/scala/tools/scalap/Decode.scala
@@ -49,7 +49,7 @@ object Decode {
import classFile._
classFile annotation SCALA_SIG_ANNOTATION map { case Annotation(_, els) =>
- val bytesElem = els find (x => constant(x.elementNameIndex) == BYTES_VALUE) getOrElse null
+ val bytesElem = els find (x => constant(x.elementNameIndex) == BYTES_VALUE) orNull
val _bytes = bytesElem.elementValue match { case ConstValueIndex(x) => constantWrapped(x) }
val bytes = _bytes.asInstanceOf[StringBytesPair].bytes
val length = ByteCodecs.decode(bytes)
diff --git a/src/scalap/scala/tools/scalap/JavaWriter.scala b/src/scalap/scala/tools/scalap/JavaWriter.scala
index 772cf6eacd..75e2637d56 100644
--- a/src/scalap/scala/tools/scalap/JavaWriter.scala
+++ b/src/scalap/scala/tools/scalap/JavaWriter.scala
@@ -164,7 +164,7 @@ class JavaWriter(classfile: Classfile, writer: Writer) extends CodeWriter(writer
}
def printClass() {
- val pck = getPackage(cf.classname);
+ val pck = getPackage(cf.classname)
if (pck.length() > 0)
println("package " + pck + ";")
print(flagsToStr(true, cf.flags))
@@ -175,14 +175,14 @@ class JavaWriter(classfile: Classfile, writer: Writer) extends CodeWriter(writer
printClassHeader;
case Some(cf.Attribute(_, data)) =>
val mp = new MetaParser(getName(
- ((data(0) & 0xff) << 8) + (data(1) & 0xff)).trim());
+ ((data(0) & 0xff) << 8) + (data(1) & 0xff)).trim())
mp.parse match {
case None => printClassHeader;
case Some(str) =>
if (isInterface(cf.flags))
- print("trait " + getSimpleClassName(cf.classname) + str);
+ print("trait " + getSimpleClassName(cf.classname) + str)
else
- print("class " + getSimpleClassName(cf.classname) + str);
+ print("class " + getSimpleClassName(cf.classname) + str)
}
}
var statics: List[cf.Member] = Nil
diff --git a/src/scalap/scala/tools/scalap/MetaParser.scala b/src/scalap/scala/tools/scalap/MetaParser.scala
index 1ebf86268a..b9dab0ad01 100644
--- a/src/scalap/scala/tools/scalap/MetaParser.scala
+++ b/src/scalap/scala/tools/scalap/MetaParser.scala
@@ -64,7 +64,7 @@ class MetaParser(meta: String) {
case _: Exception => None
}
} else
- None;
+ None
protected def parseMetaClass: String = {
nextToken
@@ -100,7 +100,7 @@ class MetaParser(meta: String) {
parseType
} while (token == "with")
}
- res.toString();
+ res.toString()
}
protected def parseMetaMethod: String = {
@@ -113,10 +113,10 @@ class MetaParser(meta: String) {
var loop = true
res.append("[")
while (loop) {
- res.append(token.substring(1));
- nextToken;
+ res.append(token.substring(1))
+ nextToken
if (token == "<") {
- nextToken;
+ nextToken
res.append(" <: ")
parseType
}
@@ -133,16 +133,16 @@ class MetaParser(meta: String) {
if (token == "(") {
do {
if (token == ",") {
- nextToken;
+ nextToken
if (token != ")")
res.append(", ")
} else {
- nextToken;
+ nextToken
res.append("(")
}
if (token != ")") {
if (token == "def") {
- nextToken;
+ nextToken
res.append("def ")
}
parseType
diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Result.scala b/src/scalap/scala/tools/scalap/scalax/rules/Result.scala
index f37340e7b7..b6f650b899 100644
--- a/src/scalap/scala/tools/scalap/scalax/rules/Result.scala
+++ b/src/scalap/scala/tools/scalap/scalax/rules/Result.scala
@@ -12,7 +12,7 @@
package scala.tools.scalap
package scalax
-package rules;
+package rules
/** Represents the combined value of two rules applied in sequence.
*
diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
index dd17c39d84..3bfb82a639 100644
--- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
+++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
@@ -91,7 +91,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
def printWithIndent(level: Int, s: String) {
def indent() {for (i <- 1 to level) print(" ")}
- indent;
+ indent
print(s)
}
@@ -208,7 +208,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
mt.resultType match {
case mt: MethodType => printMethodType(mt, printResult)({})
case x => if (printResult) {
- print(": ");
+ print(": ")
printType(x)
}
}
@@ -374,7 +374,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
}
case AnnotatedWithSelfType(typeRef, symbol, attribTreeRefs) => toString(typeRef, sep)
case ExistentialType(typeRef, symbols) => {
- val refs = symbols.map(toString _).filter(!_.startsWith("_")).map("type " + _)
+ val refs = symbols.map(toString).filter(!_.startsWith("_")).map("type " + _)
toString(typeRef, sep) + (if (refs.size > 0) refs.mkString(" forSome {", "; ", "}") else "")
}
case _ => sep + t.toString
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/jvm/innerClassEnclMethodJavaReflection.scala b/test/files/jvm/innerClassEnclMethodJavaReflection.scala
index a4d64d0b67..a60b5cac8e 100644
--- a/test/files/jvm/innerClassEnclMethodJavaReflection.scala
+++ b/test/files/jvm/innerClassEnclMethodJavaReflection.scala
@@ -25,12 +25,13 @@ object Test extends App {
def testClasses(jarOrDirectory: String): Unit = {
val classPath = AbstractFile.getDirectory(new java.io.File(jarOrDirectory))
+ val basePath = classPath.path + "/"
- def flatten(f: AbstractFile): Iterator[AbstractFile] =
- if (f.isClassContainer) f.iterator.flatMap(flatten)
- else Iterator(f)
+ def flatten(f: AbstractFile, s: String): Iterator[(AbstractFile, String)] =
+ if (f.isClassContainer) f.iterator.map(ch => (ch, (if(s.isEmpty) "" else s + "/") + ch.name)).flatMap((flatten _).tupled)
+ else Iterator((f, s))
- val classFullNames = flatten(classPath).filter(_.hasExtension("class")).map(_.path.replace("/", ".").replaceAll(".class$", ""))
+ val classFullNames = flatten(classPath, "").filter(_._1.hasExtension("class")).map(_._2.replace("/", ".").replaceAll(".class$", ""))
// it seems that Class objects can only be GC'd together with their class loader
// (http://stackoverflow.com/questions/2433261/when-and-how-are-classes-garbage-collected-in-java)
diff --git a/test/files/neg/choices.check b/test/files/neg/choices.check
index b114394e96..df4f23461f 100644
--- a/test/files/neg/choices.check
+++ b/test/files/neg/choices.check
@@ -1,2 +1,6 @@
+error: Usage: -Yresolve-term-conflict:<strategy>
+ where <strategy> choices are package, object, error (default: error)
+error: bad option: '-Yresolve-term-conflict'
error: bad options: -Yresolve-term-conflict
-one error found
+error: flags file may only contain compiler options, found: -Yresolve-term-conflict
+four errors found
diff --git a/test/files/neg/depmet_1.check b/test/files/neg/depmet_1.check
index 7a4f845fd5..15498568c5 100644
--- a/test/files/neg/depmet_1.check
+++ b/test/files/neg/depmet_1.check
@@ -1,7 +1,7 @@
-depmet_1.scala:2: error: illegal dependent method type: parameter appears in the type of another parameter in the same section or an earlier one
+depmet_1.scala:2: error: illegal dependent method type: parameter may only be referenced in a subsequent parameter section
def precise0(y: x.type)(x: String): Unit = {}
^
-depmet_1.scala:3: error: illegal dependent method type: parameter appears in the type of another parameter in the same section or an earlier one
+depmet_1.scala:3: error: illegal dependent method type: parameter may only be referenced in a subsequent parameter section
def precise1(x: String, y: x.type): Unit = {}
^
depmet_1.scala:4: error: not found: value y
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/partestInvalidFlag.check b/test/files/neg/partestInvalidFlag.check
new file mode 100644
index 0000000000..812191dc22
--- /dev/null
+++ b/test/files/neg/partestInvalidFlag.check
@@ -0,0 +1,4 @@
+error: bad option: '-badCompilerFlag'
+error: bad options: -badCompilerFlag notAFlag -Yopt:badChoice
+error: flags file may only contain compiler options, found: -badCompilerFlag notAFlag -Yopt:badChoice
+three errors found
diff --git a/test/files/neg/partestInvalidFlag.flags b/test/files/neg/partestInvalidFlag.flags
new file mode 100644
index 0000000000..68884532b9
--- /dev/null
+++ b/test/files/neg/partestInvalidFlag.flags
@@ -0,0 +1 @@
+-badCompilerFlag notAFlag -Yopt:badChoice
diff --git a/test/files/neg/partestInvalidFlag.scala b/test/files/neg/partestInvalidFlag.scala
new file mode 100644
index 0000000000..826a1a5bc2
--- /dev/null
+++ b/test/files/neg/partestInvalidFlag.scala
@@ -0,0 +1 @@
+class C
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/neg/t9572.check b/test/files/neg/t9572.check
new file mode 100644
index 0000000000..b95bd015cf
--- /dev/null
+++ b/test/files/neg/t9572.check
@@ -0,0 +1,7 @@
+t9572.scala:3: error: too many elements for tuple: 23, allowed: 22
+ val term23 = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23)
+ ^
+t9572.scala:5: error: too many elements for tuple: 23, allowed: 22
+ val type23: (Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) = null
+ ^
+two errors found
diff --git a/test/files/neg/t9572.scala b/test/files/neg/t9572.scala
new file mode 100644
index 0000000000..32b2db320e
--- /dev/null
+++ b/test/files/neg/t9572.scala
@@ -0,0 +1,6 @@
+class T9572 {
+ val term22 = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22)
+ val term23 = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23)
+ val type22: (Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) = null
+ val type23: (Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int,Int) = null
+}
diff --git a/test/files/neg/warn-unused-imports.check b/test/files/neg/warn-unused-imports.check
index 36c6dd03c3..0a53d7a9cd 100644
--- a/test/files/neg/warn-unused-imports.check
+++ b/test/files/neg/warn-unused-imports.check
@@ -1,33 +1,55 @@
-warn-unused-imports.scala:57: warning: Unused import
+warn-unused-imports_2.scala:133: error: type mismatch;
+ found : Int(42)
+ required: Sample.X
+ f(42) // error
+ ^
+warn-unused-imports_2.scala:57: warning: Unused import
import p1.A // warn
^
-warn-unused-imports.scala:62: warning: Unused import
+warn-unused-imports_2.scala:62: warning: Unused import
import p1.{ A, B } // warn on A
^
-warn-unused-imports.scala:67: warning: Unused import
+warn-unused-imports_2.scala:67: warning: Unused import
import p1.{ A, B } // warn on both
^
-warn-unused-imports.scala:67: warning: Unused import
+warn-unused-imports_2.scala:67: warning: Unused import
import p1.{ A, B } // warn on both
^
-warn-unused-imports.scala:73: warning: Unused import
+warn-unused-imports_2.scala:73: warning: Unused import
import c._ // warn
^
-warn-unused-imports.scala:78: warning: Unused import
+warn-unused-imports_2.scala:78: warning: Unused import
import p1._ // warn
^
-warn-unused-imports.scala:85: warning: Unused import
+warn-unused-imports_2.scala:85: warning: Unused import
import c._ // warn
^
-warn-unused-imports.scala:91: warning: Unused import
+warn-unused-imports_2.scala:91: warning: Unused import
import p1.c._ // warn
^
-warn-unused-imports.scala:98: warning: Unused import
+warn-unused-imports_2.scala:98: warning: Unused import
import p1._ // warn
^
-warn-unused-imports.scala:118: warning: Unused import
+warn-unused-imports_2.scala:118: warning: Unused import
import p1.A // warn
^
-error: No warnings can be incurred under -Xfatal-warnings.
-10 warnings found
+warn-unused-imports_2.scala:132: warning: Unused import
+ import Sample.Implicits._ // warn
+ ^
+warn-unused-imports_2.scala:143: warning: Unused import
+ import Sample.Implicits.useless // warn
+ ^
+warn-unused-imports_2.scala:147: warning: Unused import
+ import java.io.File // warn
+ ^
+warn-unused-imports_2.scala:148: warning: Unused import
+ import scala.concurrent.Future // warn
+ ^
+warn-unused-imports_2.scala:149: warning: Unused import
+ import scala.concurrent.ExecutionContext.Implicits.global // warn
+ ^
+warn-unused-imports_2.scala:150: warning: Unused import
+ import p1.A // warn
+ ^
+16 warnings found
one error found
diff --git a/test/files/neg/warn-unused-imports/sample_1.scala b/test/files/neg/warn-unused-imports/sample_1.scala
new file mode 100644
index 0000000000..d2f86239db
--- /dev/null
+++ b/test/files/neg/warn-unused-imports/sample_1.scala
@@ -0,0 +1,17 @@
+
+import language._
+
+object Sample {
+ trait X
+ trait Y
+
+ // import of the non-implicit should be unused
+ object Implicits {
+ def `int to X`(i: Int): X = null
+ implicit def `int to Y`(i: Int): Y = null
+ implicit def useless(i: Int): String = null
+ }
+
+ def f(x: X) = ???
+ def g(y: Y) = ???
+}
diff --git a/test/files/neg/warn-unused-imports.scala b/test/files/neg/warn-unused-imports/warn-unused-imports_2.scala
index b7a2f1c414..ded1186209 100644
--- a/test/files/neg/warn-unused-imports.scala
+++ b/test/files/neg/warn-unused-imports/warn-unused-imports_2.scala
@@ -123,3 +123,33 @@ trait Nested {
println(new Warn { })
}
}
+
+// test unusage of imports from other compilation units after implicit search
+trait Outsiders {
+ {
+ //implicit search should not disable warning
+ import Sample._
+ import Sample.Implicits._ // warn
+ f(42) // error
+ }
+ {
+ import Sample._
+ import Sample.Implicits._ // nowarn
+ g(42) // ok
+ }
+ {
+ import Sample._
+ import Sample.Implicits.`int to Y` // nowarn
+ import Sample.Implicits.useless // warn
+ g(42) // ok
+ }
+ {
+ import java.io.File // warn
+ import scala.concurrent.Future // warn
+ import scala.concurrent.ExecutionContext.Implicits.global // warn
+ import p1.A // warn
+ import p1.B // no warn
+ println("abc".bippy)
+ //Future("abc".bippy)
+ }
+}
diff --git a/test/files/pos/existental-slow-compile2.scala b/test/files/pos/existental-slow-compile2.scala
new file mode 100644
index 0000000000..907344982c
--- /dev/null
+++ b/test/files/pos/existental-slow-compile2.scala
@@ -0,0 +1,7 @@
+class C {
+ class L[+A]
+ def test = {
+ val foo:
+ L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_]]]]]]]]]]]]]]]]]]]]]]]]
+ = ??? } }
+
diff --git a/test/files/pos/existential-slow-compile1.flags b/test/files/pos/existential-slow-compile1.flags
new file mode 100644
index 0000000000..7f7581974d
--- /dev/null
+++ b/test/files/pos/existential-slow-compile1.flags
@@ -0,0 +1 @@
+-Ystop-after:refchecks
diff --git a/test/files/pos/existential-slow-compile1.scala b/test/files/pos/existential-slow-compile1.scala
new file mode 100644
index 0000000000..8602afd9db
--- /dev/null
+++ b/test/files/pos/existential-slow-compile1.scala
@@ -0,0 +1,7 @@
+class C {
+ type L[+A] = scala.collection.immutable.List[A]
+ def test = {
+ val foo:
+ L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_]]]]]]]]]]]]]]]]]]]]]]]]
+ = ??? } }
+
diff --git a/test/files/pos/t3420.flags b/test/files/pos/t3420.flags
index ea03113c66..d37e817882 100644
--- a/test/files/pos/t3420.flags
+++ b/test/files/pos/t3420.flags
@@ -1 +1 @@
--optimise -Xfatal-warnings \ No newline at end of file
+-optimise -Xfatal-warnings
diff --git a/test/files/presentation/doc/doc.scala b/test/files/presentation/doc/doc.scala
index f2233f1828..ce431910ee 100644
--- a/test/files/presentation/doc/doc.scala
+++ b/test/files/presentation/doc/doc.scala
@@ -118,6 +118,12 @@ object Test extends InteractiveTest {
}
}
+ // The remainder of this test has been found to fail intermittently on Windows
+ // only. The problem is difficult to isolate and reproduce; see
+ // https://github.com/scala/scala-dev/issues/72 for details.
+ // So if we're on Windows, let's just bail out here.
+ if (scala.util.Properties.isWin) return
+
// Check inter-classes documentation one-time retrieved ok.
val baseSource = findSource("Base.scala")
val derivedSource = findSource("Derived.scala")
diff --git a/test/files/run/repl-paste-5.check b/test/files/run/repl-paste-5.check
new file mode 100644
index 0000000000..8b97b8888d
--- /dev/null
+++ b/test/files/run/repl-paste-5.check
@@ -0,0 +1,28 @@
+
+scala> :paste < EOF
+// Entering paste mode (EOF to finish)
+
+class C { def c = 42 }
+EOF
+
+// Exiting paste mode, now interpreting.
+
+defined class C
+
+scala> new C().c
+res0: Int = 42
+
+scala> :paste <| EOF
+// Entering paste mode (EOF to finish)
+
+ |class D { def d = 42 }
+EOF
+
+// Exiting paste mode, now interpreting.
+
+defined class D
+
+scala> new D().d
+res1: Int = 42
+
+scala> :quit
diff --git a/test/files/run/repl-paste-5.scala b/test/files/run/repl-paste-5.scala
new file mode 100644
index 0000000000..890f47f141
--- /dev/null
+++ b/test/files/run/repl-paste-5.scala
@@ -0,0 +1,18 @@
+
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ //def code = ":paste < EOF\n" + (
+ def code =
+ """
+:paste < EOF
+class C { def c = 42 }
+EOF
+new C().c
+:paste <| EOF
+ |class D { def d = 42 }
+EOF
+new D().d
+ """
+ //)
+}
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/files/run/t4950.check b/test/files/run/t4950.check
deleted file mode 100644
index 8994441163..0000000000
--- a/test/files/run/t4950.check
+++ /dev/null
@@ -1,7 +0,0 @@
-
-scala> val 1 = 2
-scala.MatchError: 2 (of class java.lang.Integer)
-
-scala> val List(1) = List(1)
-
-scala> :quit
diff --git a/test/files/run/t4950.scala b/test/files/run/t4950.scala
index cef06027bf..e34b2cf3f2 100644
--- a/test/files/run/t4950.scala
+++ b/test/files/run/t4950.scala
@@ -1,12 +1,24 @@
-import scala.tools.partest.ReplTest
+import scala.tools.partest.SessionTest
+import scala.PartialFunction.{ cond => when }
+
+object Elision {
+ val elideMsg = """ ... \d+ elided""".r
+}
+
+object Test extends SessionTest {
+ import Elision._
-object Test extends ReplTest {
// Filter out the abbreviated stacktrace "... X elided"
// because the number seems to differ between versions/platforms/...
- override def show = eval() filterNot (_ contains "elided") foreach println
- def code =
+ def elided(s: String) = when(s) { case elideMsg() => true }
+ override def eval() = super.eval() filterNot elided
+ def session =
"""
-val 1 = 2
-val List(1) = List(1)
+scala> val 1 = 2
+scala.MatchError: 2 (of class java.lang.Integer)
+
+scala> val List(1) = List(1)
+
+scala> :quit
"""
}
diff --git a/test/files/run/t7634.check b/test/files/run/t7634.check
index 879aea67a2..43128cad95 100644
--- a/test/files/run/t7634.check
+++ b/test/files/run/t7634.check
@@ -1,6 +1,6 @@
-scala> .lines
-res1: List[String] = List(shello, world.)
+scala> .lines.foreach(println)
+shello, world.
scala> :quit
diff --git a/test/files/run/t7634.scala b/test/files/run/t7634.scala
index aeb6a5e671..9520931941 100644
--- a/test/files/run/t7634.scala
+++ b/test/files/run/t7634.scala
@@ -9,7 +9,7 @@ import scala.util.Properties.propOrElse
object Test extends ReplTest {
def java = propOrElse("javacmd", "java")
def code = s""":sh $java -classpath $testOutput hello.Hello
- |.lines""".stripMargin
+ |.lines.foreach(println)""".stripMargin
}
package hello {
diff --git a/test/files/run/t9546.scala b/test/files/run/t9546.scala
new file mode 100644
index 0000000000..7016881084
--- /dev/null
+++ b/test/files/run/t9546.scala
@@ -0,0 +1,13 @@
+package foo {
+ case class Opt[A] private[foo](val get: A) extends AnyVal
+ object Opt {
+ def mkOpt = Opt("")
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ foo.Opt.mkOpt
+ }
+}
+
diff --git a/test/files/run/t9546b.scala b/test/files/run/t9546b.scala
new file mode 100644
index 0000000000..0b4d2d3fe5
--- /dev/null
+++ b/test/files/run/t9546b.scala
@@ -0,0 +1,13 @@
+package foo {
+ case class Opt[A](val get: A) extends AnyVal {
+ }
+ object Opt {
+ def mkOpt = Opt("")
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ foo.Opt.mkOpt
+ }
+}
diff --git a/test/files/run/t9546c.scala b/test/files/run/t9546c.scala
new file mode 100644
index 0000000000..ea6a5a36b4
--- /dev/null
+++ b/test/files/run/t9546c.scala
@@ -0,0 +1,13 @@
+package foo {
+ case class Opt[A] private[foo](val get: A)
+ object Opt {
+ def mkOpt = Opt("")
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ foo.Opt.mkOpt
+ }
+}
+
diff --git a/test/files/run/t9546d.scala b/test/files/run/t9546d.scala
new file mode 100644
index 0000000000..00bf37dc18
--- /dev/null
+++ b/test/files/run/t9546d.scala
@@ -0,0 +1,16 @@
+class X {
+ def test: Any = {
+ object Opt {
+ def mkOpt = Opt("")
+ }
+ case class Opt[A] private[X](val get: A)
+ Opt.mkOpt
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ new X().test
+ }
+}
+
diff --git a/test/files/run/t9546e.scala b/test/files/run/t9546e.scala
new file mode 100644
index 0000000000..b19d0871aa
--- /dev/null
+++ b/test/files/run/t9546e.scala
@@ -0,0 +1,15 @@
+case class A private (x: Int)
+case class B private (x: Int)(y: Int)
+
+class C {
+ def f = A(1)
+ def g = B(1)(2) // was: constructor B in class B cannot be accessed in class C
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ new C().f
+ new C().g
+ }
+
+}
diff --git a/test/files/run/t9567.scala b/test/files/run/t9567.scala
new file mode 100644
index 0000000000..69896b8650
--- /dev/null
+++ b/test/files/run/t9567.scala
@@ -0,0 +1,18 @@
+object Test {
+ def testMethodLocalCaseClass {
+ case class MethodLocalWide(
+ f01: Int, f02: Int, f03: Int, f04: Int, f05: Int, f06: Int, f07: Int, f08: Int, f09: Int, f10: Int,
+ f11: Int, f12: Int, f13: Int, f14: Int, f15: Int, f16: Int, f17: Int, f18: Int, f19: Int, f20: Int,
+ f21: Int, f22: Int, f23: Int)
+
+ val instance = MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+ val result = instance match {
+ case MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) => true
+ case _ => false
+ }
+ assert(result)
+ }
+ def main(args: Array[String]) {
+ testMethodLocalCaseClass
+ }
+}
diff --git a/test/files/run/t9567b.scala b/test/files/run/t9567b.scala
new file mode 100644
index 0000000000..88cef0a60e
--- /dev/null
+++ b/test/files/run/t9567b.scala
@@ -0,0 +1,19 @@
+object Test {
+ def testMethodLocalCaseClass {
+ object MethodLocalWide
+ case class MethodLocalWide(
+ f01: Int, f02: Int, f03: Int, f04: Int, f05: Int, f06: Int, f07: Int, f08: Int, f09: Int, f10: Int,
+ f11: Int, f12: Int, f13: Int, f14: Int, f15: Int, f16: Int, f17: Int, f18: Int, f19: Int, f20: Int,
+ f21: Int, f22: Int, f23: Int)
+
+ val instance = MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+ val result = instance match {
+ case MethodLocalWide(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) => true
+ case _ => false
+ }
+ assert(result)
+ }
+ def main(args: Array[String]) {
+ testMethodLocalCaseClass
+ }
+}
diff --git a/test/files/run/t9567c.scala b/test/files/run/t9567c.scala
new file mode 100644
index 0000000000..560bea8821
--- /dev/null
+++ b/test/files/run/t9567c.scala
@@ -0,0 +1,29 @@
+case class CaseSequenceTopLevel(as: Int*)
+
+object Test {
+ def main(args: Array[String]): Unit = {
+
+ val buffer1 = collection.mutable.Buffer(0, 0)
+ CaseSequenceTopLevel(buffer1: _*) match {
+ case CaseSequenceTopLevel(_, i) =>
+ buffer1(1) = 1
+ assert(i == 0, i) // fails in 2.11.7 -optimize
+ }
+
+ case class CaseSequence(as: Int*)
+ val buffer2 = collection.mutable.Buffer(0, 0)
+ CaseSequence(buffer2: _*) match {
+ case CaseSequence(_, i) =>
+ buffer2(1) = 1
+ assert(i == 0, i)
+ }
+
+ case class CaseSequenceWithVar(var x: Any, as: Int*)
+ val buffer3 = collection.mutable.Buffer(0, 0)
+ CaseSequenceWithVar("", buffer3: _*) match {
+ case CaseSequenceWithVar(_, _, i) => // crashes in 2.11.7
+ buffer2(1) = 1
+ assert(i == 0, i)
+ }
+ }
+}
diff --git a/test/junit/scala/collection/IteratorTest.scala b/test/junit/scala/collection/IteratorTest.scala
index 1c1e50aed9..329c85127a 100644
--- a/test/junit/scala/collection/IteratorTest.scala
+++ b/test/junit/scala/collection/IteratorTest.scala
@@ -164,4 +164,32 @@ class IteratorTest {
assertEquals(1, y.next)
assertFalse(x.hasNext) // was true, after advancing underlying iterator
}
+ // SI-9623
+ @Test def noExcessiveHasNextInJoinIterator: Unit = {
+ var counter = 0
+ val exp = List(1,2,3,1,2,3)
+ def it: Iterator[Int] = new Iterator[Int] {
+ val parent = List(1,2,3).iterator
+ def next(): Int = parent.next
+ def hasNext: Boolean = { counter += 1; parent.hasNext }
+ }
+ // Iterate separately
+ val res = new mutable.ArrayBuffer[Int]
+ it.foreach(res += _)
+ it.foreach(res += _)
+ assertSameElements(exp, res)
+ assertEquals(8, counter)
+ // JoinIterator
+ counter = 0
+ res.clear
+ (it ++ it).foreach(res += _)
+ assertSameElements(exp, res)
+ assertEquals(8, counter) // was 17
+ // ConcatIterator
+ counter = 0
+ res.clear
+ (Iterator.empty ++ it ++ it).foreach(res += _)
+ assertSameElements(exp, res)
+ assertEquals(8, counter) // was 14
+ }
}
diff --git a/test/junit/scala/collection/SearchingTest.scala b/test/junit/scala/collection/SearchingTest.scala
new file mode 100644
index 0000000000..2f939d625e
--- /dev/null
+++ b/test/junit/scala/collection/SearchingTest.scala
@@ -0,0 +1,48 @@
+package scala.collection
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Assert._
+import org.junit.Test
+import scala.collection.Searching._
+
+@RunWith(classOf[JUnit4])
+class SearchingTest {
+
+ @Test
+ def doesLinearSearchOnLinearSeqs() {
+
+ class TestSeq[A](list: List[A]) extends SeqLike[A, TestSeq[A]] {
+ var elementsAccessed = Set.empty[Int]
+
+ protected[this] def newBuilder = ??? // not needed for this test
+ def seq = list
+ def iterator = list.iterator
+ def length = list.length
+ def apply(idx: Int) = { elementsAccessed += idx; list(idx) }
+ }
+
+ val coll = new TestSeq((0 to 6).toList)
+
+ assertEquals(Found(5), coll.search(5))
+ assertEquals(Set.empty, coll.elementsAccessed) // linear search should not access elements via apply()
+ }
+
+ @Test
+ def doesBinarySearchOnIndexedSeqs() {
+
+ class TestIndexedSeq[A](vec: Vector[A]) extends IndexedSeqLike[A, TestIndexedSeq[A]] {
+ var elementsAccessed = Set.empty[Int]
+
+ protected[this] def newBuilder = ??? // not needed for this test
+ def seq = vec
+ def length = vec.length
+ def apply(idx: Int) = { elementsAccessed += idx; vec(idx) }
+ }
+
+ val coll = new TestIndexedSeq((0 to 6).toVector)
+
+ assertEquals(Found(5), coll.search(5))
+ assertEquals(Set(3, 5), coll.elementsAccessed)
+ }
+}
diff --git a/test/junit/scala/collection/immutable/VectorTest.scala b/test/junit/scala/collection/immutable/VectorTest.scala
new file mode 100644
index 0000000000..69f74872d0
--- /dev/null
+++ b/test/junit/scala/collection/immutable/VectorTest.scala
@@ -0,0 +1,30 @@
+package scala.collection.immutable
+
+import org.junit.Assert._
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+
+@RunWith(classOf[JUnit4])
+class VectorTest {
+
+ @Test
+ def hasCorrectDropAndTakeMethods() {
+ val v = Vector(0) ++ Vector(1 to 64: _*)
+
+ assertEquals(Vector(0, 1), v take 2)
+ assertEquals(Vector(63, 64), v takeRight 2)
+ assertEquals(Vector(2 to 64: _*), v drop 2)
+ assertEquals(Vector(0 to 62: _*), v dropRight 2)
+
+ assertEquals(v, v take Int.MaxValue)
+ assertEquals(v, v takeRight Int.MaxValue)
+ assertEquals(Vector.empty[Int], v drop Int.MaxValue)
+ assertEquals(Vector.empty[Int], v dropRight Int.MaxValue)
+
+ assertEquals(Vector.empty[Int], v take Int.MinValue)
+ assertEquals(Vector.empty[Int], v takeRight Int.MinValue)
+ assertEquals(v, v drop Int.MinValue)
+ assertEquals(v, v dropRight Int.MinValue)
+ }
+}
diff --git a/test/junit/scala/collection/mutable/OpenHashMapTest.scala b/test/junit/scala/collection/mutable/OpenHashMapTest.scala
new file mode 100644
index 0000000000..1459c14d78
--- /dev/null
+++ b/test/junit/scala/collection/mutable/OpenHashMapTest.scala
@@ -0,0 +1,42 @@
+package scala.collection.mutable
+
+import org.junit.Test
+import org.junit.Assert._
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+/** Tests for [[OpenHashMap]]. */
+@RunWith(classOf[JUnit4])
+class OpenHashMapTest {
+ /** Test that an [[OpenHashMap]] correctly maintains its internal `deleted` count. */
+ @Test
+ def maintainsDeletedCount {
+ val m = OpenHashMap.empty[Int, Int]
+
+ // Reflect to get the private `deleted` field's value, which should be zero.
+
+ /* TODO Doesn't work, due to SI-9306.
+ import scala.reflect.runtime.{universe => ru}
+
+ val mirror = ru.runtimeMirror(m.getClass.getClassLoader)
+ val mapType = ru.typeOf[OpenHashMap[Int, Int]]
+ val termSym = mapType.decls
+ .filterNot { s => s.isMethod }
+ .filter { s => s.fullName.endsWith("deleted") }
+ .head.asTerm
+
+ val fieldMirror = mirror.reflect(m).reflectField(termSym)
+ */
+ // Use Java reflection instead for now.
+ val field = m.getClass.getDeclaredField("scala$collection$mutable$OpenHashMap$$deleted")
+ field.setAccessible(true)
+
+ m.put(0, 0)
+ m.remove(0)
+ assertEquals(1, field.getInt(m))
+
+ m.put(0, 0) // Add an entry with the same key
+ // TODO assertEquals(0, fieldMirror.get.asInstanceOf[Int])
+ assertEquals(0, field.getInt(m))
+ }
+}
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/reflect/ClassTag.scala b/test/junit/scala/reflect/ClassTag.scala
index 90cc981fc1..49022dccda 100644
--- a/test/junit/scala/reflect/ClassTag.scala
+++ b/test/junit/scala/reflect/ClassTag.scala
@@ -26,4 +26,14 @@ class ClassTagTest {
@Test def checkDouble = assertTrue(checkNotInt[Double] (0.toDouble))
@Test def checkBoolean = assertTrue(checkNotInt[Boolean](false))
@Test def checkUnit = assertTrue(checkNotInt[Unit] ({}))
-} \ No newline at end of file
+
+ @Test def t9534: Unit = {
+ val ct = implicitly[scala.reflect.ClassTag[Unit]]
+ val a1 = ct.newArray(1)
+ a1(0) = ()
+ val a2 = ct.wrap.newArray(1)
+ a2(0) = a1
+ val a3 = ct.newArray2(1)
+ a3(0) = a1
+ }
+}
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/partest b/test/partest
index 8b827f276f..cb07c00e04 100755
--- a/test/partest
+++ b/test/partest
@@ -22,6 +22,14 @@ findScalaHome () {
}
# Use tput to detect color-capable terminal.
+# (note: I have found that on Cygwin, the script sometimes dies here.
+# it doesn't happen from the Cygwin prompt when ssh'ing in to
+# jenkins-worker-windows-publish, only when I make a Jenkins job
+# that runs this script. I don't know why. it may have to do with
+# which bash flags are set (-e? -x?) and with bash flags propagating
+# from one script to another? not sure. anyway, normally in a CI
+# context we run partest through ant, not through this script, so I'm
+# not investigating further for now.)
term_colors=$(tput colors 2>/dev/null)
if [[ $? == 0 ]] && [[ $term_colors -gt 2 ]]; then
git_diff_options="--color=always --word-diff"
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"
diff --git a/test/scaladoc/run/tag-requirements.check b/test/scaladoc/run/tag-requirements.check
new file mode 100644
index 0000000000..184273b883
--- /dev/null
+++ b/test/scaladoc/run/tag-requirements.check
@@ -0,0 +1,16 @@
+newSource:3: warning: Only one '@version' tag is allowed
+ /**
+ ^
+newSource:9: warning: Tag '@param' must be followed by a symbol name
+ /**
+ ^
+newSource:9: warning: Tag '@param' is not recognised
+ /**
+ ^
+newSource:14: warning: Only one '@param' tag for symbol b is allowed
+ /**
+ ^
+newSource:20: warning: Tag '@unrecognised' is not recognised
+ /**
+ ^
+Done.
diff --git a/test/scaladoc/run/tag-requirements.scala b/test/scaladoc/run/tag-requirements.scala
new file mode 100644
index 0000000000..24f1fab761
--- /dev/null
+++ b/test/scaladoc/run/tag-requirements.scala
@@ -0,0 +1,53 @@
+import scala.tools.nsc.doc.base._
+import scala.tools.nsc.doc.model._
+import scala.tools.partest.ScaladocModelTest
+
+object Test extends ScaladocModelTest {
+
+ override def code =
+ """
+ package scala.test.scaladoc.tagrequirements
+ /**
+ * object comment
+ * @version 1.0
+ * @version 2.0
+ */
+ object Test {
+ /**
+ * foo comment
+ * @param
+ */
+ def foo(b: Any) = ???
+ /**
+ * bar comment
+ * @param b A value
+ * @param b A value
+ */
+ def bar(b: Any) = ???
+ /**
+ * baz comment
+ * @unrecognised
+ */
+ def baz() = ???
+ }
+ """
+
+ def scaladocSettings = ""
+
+ def testModel(root: Package) = {
+ // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
+ import access._
+
+ val base = root._package("scala")._package("test")._package("scaladoc")._package("tagrequirements")
+
+ val test = base._object("Test")
+ /*
+ * We only care about the warnings which are side effects but we assert on the comment to
+ * avoid static code analysis noise about unused values.
+ */
+ assert(extractCommentText(test.comment.get) == "object comment")
+ assert(extractCommentText(test._method("foo").comment.get) == "foo comment")
+ assert(extractCommentText(test._method("bar").comment.get) == "bar comment")
+ assert(extractCommentText(test._method("baz").comment.get) == "baz comment")
+ }
+}
diff --git a/tools/get-scala-commit-date.bat b/tools/get-scala-commit-date.bat
index e169de1b04..735a80b927 100644
--- a/tools/get-scala-commit-date.bat
+++ b/tools/get-scala-commit-date.bat
@@ -1,9 +1,9 @@
@echo off
for %%X in (bash.exe) do (set FOUND=%%~$PATH:X)
if defined FOUND (
- bash "%~dp0\get-scala-commit-date"
+ bash "%~dp0\get-scala-commit-date" 2>NUL
) else (
rem echo this script does not work with cmd.exe. please, install bash
echo unknown
exit 1
-) \ No newline at end of file
+)
diff --git a/tools/get-scala-commit-sha.bat b/tools/get-scala-commit-sha.bat
index 1eaffc0a15..6559a19120 100644
--- a/tools/get-scala-commit-sha.bat
+++ b/tools/get-scala-commit-sha.bat
@@ -1,9 +1,9 @@
@echo off
for %%X in (bash.exe) do (set FOUND=%%~$PATH:X)
if defined FOUND (
- bash "%~dp0\get-scala-commit-sha"
+ bash "%~dp0\get-scala-commit-sha" 2>NUL
) else (
rem echo this script does not work with cmd.exe. please, install bash
echo unknown
exit 1
-) \ No newline at end of file
+)
diff --git a/tools/scaladoc-diff b/tools/scaladoc-diff
new file mode 100755
index 0000000000..df0d1f3335
--- /dev/null
+++ b/tools/scaladoc-diff
@@ -0,0 +1,117 @@
+#!/usr/bin/env bash
+#
+# Script to compare the scaladoc of the current commit with the scaladoc
+# of the parent commit. No arguments.
+#
+
+set -e
+
+# opendiff for Mac OS X, meld for Ubuntu then default to other commands.
+displaydiff() {
+ case "$(uname -s)" in
+
+ Darwin)
+ if hash opendiff 2>/dev/null; then
+ echo opendiff "$@"
+ opendiff "$@"
+ else
+ echo diff "$@"
+ diff -y "$@" | less -N
+ fi
+ ;;
+
+ *)
+ if hash meld 2>/dev/null; then
+ echo meld "$@"
+ meld "$@"
+ elif hash gvimdiff 2>/dev/null; then
+ echo gvimdiff "$@"
+ gvimdiff "$@"
+ else
+ echo diff "$@"
+ diff -y "$@" | less -N
+ fi
+ ;;
+ esac
+}
+
+oldsha=$(git rev-parse --short HEAD^)
+
+# Use branch name defaulting to SHA1 when not available for example when in
+# detached HEAD state.
+sha=$(git symbolic-ref -q --short HEAD || git rev-parse --short HEAD)
+
+echo "parent commit sha : $oldsha"
+echo "current commit sha : $sha"
+
+# create scaladoc for parent commit if not done already
+if [ ! -f "build/scaladoc-output-$oldsha.txt" ]
+then
+ echo "making scaladoc for parent commit ($oldsha)"
+ git checkout -q $oldsha
+ ant docs.lib -Dscaladoc.raw.output='yes' > build/scaladoc-output-$oldsha.txt
+ rm -rf build/scaladoc-${oldsha}
+ mv build/scaladoc build/scaladoc-${oldsha}
+ git checkout -q $sha
+fi
+
+# create scaladoc for current commit
+echo "making scaladoc for current commit ($sha)"
+ant docs.lib -Dscaladoc.raw.output='yes' > build/scaladoc-output-$sha.txt
+rm -rf build/scaladoc-${sha}
+mv build/scaladoc build/scaladoc-${sha}
+
+# Allow script to continue when diff results in -1
+set +e
+
+displaydiff build/scaladoc-output-$oldsha.txt build/scaladoc-output-$sha.txt
+
+# Adapted from tools/scaladoc-compare
+echo "Comparing versions with diff: build/scaladoc-${sha}/ build/scaladoc-$oldsha/"
+NEW_PATH=build/scaladoc-${sha}/
+OLD_PATH=build/scaladoc-$oldsha/
+
+
+NEWFILES=$(find $NEW_PATH -name '*.html.raw')
+if [ "$NEWFILES" == "" ]
+then
+ echo "No .html.raw files found in $NEW_PATH!"
+ exit 1
+fi
+
+for NEW_FILE in $NEWFILES
+do
+ OLD_FILE=${NEW_FILE/$NEW_PATH/$OLD_PATH}
+ if [ -f $OLD_FILE ]
+ then
+ DIFF=$(diff -q -w $NEW_FILE $OLD_FILE 2>&1)
+ if [ "$DIFF" != "" ]
+ then
+ displaydiff $OLD_FILE $NEW_FILE > /dev/null
+
+ echo "next [y\N]? "
+ read -n 1 -s input
+ if [ "$input" == "N" ]; then exit 0; fi
+ fi
+ else
+ echo
+ echo "New file: : $NEW_FILE"
+ echo "No corresponding old file : $OLD_FILE"
+
+ echo "next [y\N]? "
+ read -n 1 -s input
+ if [ "$input" == "N" ]; then exit 0; fi
+ fi
+done
+
+OLDFILES=$(find $OLD_PATH -name '*.html.raw')
+for OLD_FILE in $OLDFILES
+do
+ NEW_FILE=${OLD_FILE/$OLD_PATH/$NEW_PATH}
+ if [ ! -f $NEW_FILE ]
+ then
+ echo
+ echo "Old file: : $OLD_FILE"
+ echo "No corresponding new file : $NEW_FILE"
+ fi
+done
diff --git a/versions.properties b/versions.properties
index 2253921940..45dada9778 100644
--- a/versions.properties
+++ b/versions.properties
@@ -36,7 +36,7 @@ jline.version=2.12.1
scala-asm.version=5.0.4-scala-3
# external modules, used internally (not shipped)
-partest.version.number=1.0.9
+partest.version.number=1.0.13
scalacheck.version.number=1.11.6
# TODO: modularize the compiler