summaryrefslogtreecommitdiff
path: root/src/library
Commit message (Collapse)AuthorAgeFilesLines
* Collections library tidying and deprecation. Separate parts are listed below.Rex Kerr2013-11-0770-17/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Collections library tidying, part one: scripting. Everything in scala.collection.scripting is deprecated now, along with the << method that is implemented in a few other classes. Scripting does not seem used at all, and anyone who did can easily write a wrapper that does the same thing. Deprecated *Proxy collections. The only place proxies were used in the library was in swing.ListView, and that was easy to change to a lazy val. Proxy itself is used in ScalaNumberProxy and such, so it was left undeprecated. Deprecated Synchronized* traits from collections. Synchronizability does not compose well, and it requires careful examination of every method (which has not actually been done). Places where the Scala codebase needs to be fixed (eventually) include: scala.reflect.internal.util.Statistics$QuantMap scala.tools.nsc.interactive.Global (several places) Deprecated LinkedList (including Double- and -Like variants). Interface is idiosyncratic and dangerously low-level. Although some low-level functionality of this sort would be useful, this doesn't seem to be the ideal implementation. Also deprecated the extractFirst method in Queue as it exposes LinkedList. Cannot shift internal representations away from LinkedList at this time because of that method. Deprecated non-finality of several toX collection methods. Improved documentation of most toX collection methods to describe what the expectation is for their behavior. Additionally deprecated overriding of - toIterator in IterableLike (should always forward to iterator) - toTraversable in TraversableLike (should always return self) - toIndexedSeq in immutable.IndexedSeq (should always return self) - toMap in immutable.Map (should always return self) - toSet in immutable.Set (should always return self) Did not do anything with IterableLike.toIterable or Seq/SeqLike.toSeq since for some odd reason immutable.Range overrides those. Deprecated Forwarders from collections. Forwarding, without an automatic mechanism to keep up to date with changes in the forwarded class, is inherently unreliable. Absent a mechanism to keep current, they're deprecated. ListBuffer is the only class in the collections library that uses forwarders, and that functionality can be rolled into ListBuffer itself. Deprecating immutable set/map adaptors. They're a bad idea (barring compiler support) for the same reason that all the other adaptors are a bad idea: they get out of date and probably have a variety of performance bugs. Deprecated inheritance from leaf classes in immutable collections. Inheriting from leaf-classes in immutable collections is rarely a good idea since whenever you use any interesting collections method you'll revert to the original class. Also, the methods are often designed to work with only particular behavior, and an override would be difficult (at best) to make work. Fortunately, people seem to have realized this and there are few to no cases of people extending PagedSeq and TreeSet and the like. Note that in many cases the classes will become sealed not final. Deprecated overriding of methods and inheritance from various mutable collections. Some mutable collections seem unsuited for overriding since to override anything interesting you would need vast knowledge of internal data structures and/or access to private methods. These include - ArrayBuilder.ofX classes. - ArrayOps - Some methods of BitSet (moved others from private to protected final) - Some methods of HashTable and FlatHashTable - Some methods of HashMap and HashSet (esp += and -= which just forward) - Some methods of other maps and sets (LinkedHashX, ListMap, TreeSet) - PriorityQueue - UnrolledBuffer This is a somewhat aggressive deprecation, the theory being better to try it out now and back off if it's too much than not attempt the change and be stuck with collections that can neither be safely inherited nor have implementation details changed. Note that I have made no changes--in this commit--which would cause deprecation warnings in any of the Scala projects available on Maven (at least as gathered by Adriaan). There are deprecation warnings induced within the library (esp. for classes/traits that should become static) and the compiler. I have not attempted to fix all the deprecations in the compiler as some of them touch the IDE API (but these mostly involved Synchronized which is inherently unsafe, so this should be fixed eventually in coordination with the IDE code base(s)). Updated test checks to include new deprecations. Used a higher level implementation for messages in JavapClass.
* Merge pull request #3086 from axel22/topic/pc-execution-contextAdriaan Moors2013-11-052-10/+87
|\ | | | | - parallel collections should use default ExecutionContext
| * SI-7938 - parallel collections should use default ExecutionContextAleksandar Prokopec2013-10-292-10/+87
| | | | | | | | | | | | | | | | | | | | Parallel collections now use `scala.concurrent.ExecutionContext` by default. The `ExecutionContextTaskSupport` is optimized to use the `ForkJoinPool` underlying the `ExecutionContext` if possible. Otherwise, a fallback `TaskSupport` that creates a reduction tree and execute an operation through `Future`s is used.
* | from Issue #3098Xusen Yin2013-11-051-2/+2
| | | | | | from Issue #3098, some typos.
* | Collections: remove redundant calls to .seqJason Zaugg2013-10-319-13/+13
|/ | | | | | | | | | | | | | | | | | | | | | | | Students of Scala's history might recall that at introduction of parallel collections, GenIterable et al were *not* added; instead the parallel collections inherited from the existing interfaces. This of course was an invitation to widespread disaster as any existing code that foreach-ed over a collection might now experience unwanted concurrency. The first attempt to fix this was to add the `.seq` method to convert a parallel colleciton to a sequential one. This was added in e579152f732, and call sites in the standard library with side-effecting foreach calls were changed to use that. But this was (rightly) deemed inadequate, as we could hardly expect people to change existing code or remember to do this in new code. So later, in 3de96153e5b, GenIterable was sprouted, and parallel collections were re-parented. This commit removes residual needless calls to .seq when the static type of the receiver is already a plain Iterable, which are no-ops.
* Merge pull request #3079 from jamesward/fix/ec-implicit-errorJames Iry2013-10-251-1/+1
|\ | | | | More clear implicitNotFound error for ExecutionContext
| * More clear implicitNotFound error for ExecutionContextJames Ward2013-10-241-1/+1
| |
* | Merge pull request #3006 from ivmaykov/masterAdriaan Moors2013-10-241-0/+9
|\ \ | |/ |/| SI-7883 - don't iterate over all keys in MapWrapper.containsKey()
| * SI-7883: Added a comment per CR feedback from @adriaanm, @IchoranIlya Maykov2013-10-031-0/+3
| |
| * SI-7883 - don't iterate over all keys in MapWrapper.containsKey()Ilya Maykov2013-10-011-0/+6
| |
* | IterableLike.grouped() : More explicit documentationValerian2013-10-141-1/+1
| |
* | IterableLike grouped : fix documentationValerian2013-10-101-1/+1
| | | | | | | | scala> Seq(1,2,3).grouped(2).toList res1: List[Seq[Int]] = List(List(1, 2), List(3))
* | Merge pull request #3014 from ceedubs/pr/implicitNotFound-scaladocAdriaan Moors2013-10-071-2/+5
|\ \ | | | | | | Describe type parameter interpolation in @implicitNotFound documentation
| * | Describe type parameter interpolation in @implicitNotFound documentationCody Allen2013-10-031-2/+5
| | | | | | | | | | | | | | | | | | Using this feature is necessary for helpful error messages, so it should be documented. Thank you to @adriaanm for recommending the this description.
* | | Merge pull request #3005 from paulp/pr/7886Paul Phillips2013-10-031-1/+1
|\ \ \ | |/ / |/| | SI-7886 unsoundness in pattern matcher.
| * | SI-6680 unsoundness in gadt typing.Paul Phillips2013-10-011-1/+1
| |/ | | | | | | | | | | | | Introduces -Xstrict-inference to deal with the significant gap between soundness and what presently compiles. I'm hopeful that it's TOO strict, because it finds e.g. 75 errors compiling immutable/IntMap.scala, but it might be that bad.
* / Removing unused code.Paul Phillips2013-10-022-1/+2
|/ | | | | | | Most of this was revealed via -Xlint with a flag which assumes closed world. I can't see how to check the assumes-closed-world code in without it being an ordeal. I'll leave it in a branch in case anyone wants to finish the long slog to the merge.
* Merge remote-tracking branch 'origin/2.10.x' into merge/2.10.x-to-master-2Jason Zaugg2013-09-271-7/+4
|\ | | | | | | | | | | | | | | | | | | Conflicts: bincompat-backward.whitelist.conf bincompat-forward.whitelist.conf build.xml src/compiler/scala/tools/nsc/typechecker/RefChecks.scala src/library/scala/concurrent/Future.scala src/reflect/scala/reflect/internal/Types.scala
| * SI-7861 Don't execute internal callbacks on the user ExecutorJason Zaugg2013-09-211-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Callbacks internal to the implementation of Futures should be executed with the `InternalCallbackExecutor`, rather than the user supplied `Executor`. In a refactoring da54f34a6, `recoverWith` and `flatMap` no longer played by these rules. This was noticed by a persnickety test in Play. Before this patch, the enclosed test outputs: % scala-hash v2.10.3-RC2 test/files/run/future-flatmap-exec-count.scala mapping execute() flatmapping execute() execute() recovering execute() execute()
* | Remove octal escape literals from the codebaseSimon Schaefer2013-09-251-22/+22
| | | | | | | | | | Octal escape literals are deprecated and will be removed in the next Scala version.
* | Merge pull request #2938 from Ichoran/issue/7725Jason Zaugg2013-09-231-3/+26
|\ \ | | | | | | SI-7725 - Vector concatenation is unreasonably slow
| * | SI-7725 - Vector concatenation is unreasonably slowRex Kerr2013-09-201-3/+26
| | | | | | | | | | | | | | | | | | | | | | | | Rewrote ++ to use append or prepend when adding small collections to the end or beginning of vectors. This solves the extra-O(n) problem for addition of single elements reported in SI_7725. Renamed LgConcatFaster to Log2ConcatFaster (more widely recognizable).
* | | Merge pull request #2953 from jiaweihli/masterJason Zaugg2013-09-231-1/+1
|\ \ \ | | | | | | | | Fix typo in documentation.
| * | | Fix typo in documentation.Jiawei Li2013-09-161-1/+1
| | | |
* | | | Convenience methods from Try[T] => {Future, Promise}[T]Jason Zaugg2013-09-192-2/+16
| |/ / |/| |
* | | Cull extraneous whitespace.Paul Phillips2013-09-1870-515/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One last flurry with the broom before I leave you slobs to code in your own filth. Eliminated all the trailing whitespace I could manage, with special prejudice reserved for the test cases which depended on the preservation of trailing whitespace. Was reminded I cannot figure out how to eliminate the trailing space on the "scala> " prompt in repl transcripts. At least reduced the number of such empty prompts by trimming transcript code on the way in. Routed ConsoleReporter's "printMessage" through a trailing whitespace stripping method which might help futureproof against the future of whitespace diseases. Deleted the up-to-40 lines of trailing whitespace found in various library files. It seems like only yesterday we performed whitespace surgery on the whole repo. Clearly it doesn't stick very well. I suggest it would work better to enforce a few requirements on the way in.
* | | SI-7841 Remove AnyRef specialization from AbstractPartialFunctionJason Zaugg2013-09-161-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | This was missed in cc3badae1 Compatibility classes for formerly specialized variants used by Scalacheck have been added as a stopgap measure until we publish the next milestone.
* | | SI-7841 Remove commented out AnyRef specialization from Function{0,1}.Jason Zaugg2013-09-153-3/+3
|/ / | | | | | | In a sign of decreased optimism about that facility.
* | Merge remote-tracking branch 'origin/master' into merge/2.10.x-to-masterJason Zaugg2013-09-112-24/+49
|\ \ | | | | | | | | | | | | Conflicts: src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
| * \ Merge pull request #2927 from Ichoran/issue/7708Grzegorz Kossakowski2013-09-111-10/+17
| |\ \ | | | | | | | | SI-7708 - Improve Bitset foreach performance
| | * | SI-7708 - Improve Bitset foreach performanceRex Kerr2013-09-091-10/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Switched inner for loop for a while loop to enable early exit when bitset is sparse. 2. Switched outer for loop for while loop for performance. 3. Changed WordLength and friends to final for performance. New version runs in 60% of time of old on dense bitsets, faster if highly sparse. No tests committed (requires performance testing framework).
| * | | SI-7356 - Source.mkString performs painfully slow (...)Rex Kerr2013-09-101-14/+32
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Wrote a custom mkString for BufferedSource. 2. Moved the logic for rescuing the iterator-buffered char out of BufferedLineIterator and into a private method in BufferedSource. Speed test based on the one in the issue tracker (but written correctly) indicates that performance is equal or better to getLines. This resolves SI-7356 in a minimal fashion.
* | | Merge remote-tracking branch 'origin/2.10.x' into merge/2.10.x-to-masterJason Zaugg2013-09-103-38/+36
|\ \ \ | |/ / |/| / | |/ | | Conflicts: src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala
| * Merge pull request #2866 from retronym/ticket/7269Jason Zaugg2013-09-092-3/+5
| |\ | | | | | | SI-7269 Rework MapLike#retains to account for desugaring change
| | * SI-7269 Rework MapLike#retains to account for desugaring changeJason Zaugg2013-08-292-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `MapLike#retains` contains a for-comprehension that relied on the strict `filter` by its generator. You can't, in general, iterate a mutable map and remove items in the same pass. Here's the history of the desugaring of: def retain[A, B](thiz: mutable.Map[A, B])(p: (A, B) => Boolean): thiz.type = { thiz.foreach { case (k, v) => if (p(k, v)) thiz -= k } Before regression (c82ecabad6~1): thiz.filter(((check$ifrefutable$1) => check$ifrefutable$1: @scala.unchecked match { case scala.Tuple2((k @ _), (v @ _)) => true case _ => false })).withFilter(((x$1) => x$1: @scala.unchecked match { case scala.Tuple2((k @ _), (v @ _)) => p(k, v).unary_$bang })).foreach(((x$2) => x$2: @scala.unchecked match { case scala.Tuple2((k @ _), (v @ _)) => thiz.$minus$eq(k) })); After regression (c82ecabad6, which incorrectly assumed in the parser that no filter is required for isInstanceOf[Tuple2]) thiz.withFilter(((x$1) => x$1: @scala.unchecked match { case scala.Tuple2((k @ _), (v @ _)) => p(k, v).unary_$bang })).foreach(((x$2) => x$2: @scala.unchecked match { case scala.Tuple2((k @ _), (v @ _)) => thiz.$minus$eq(k) })); After the reversion of c82ecabad6, v2.10.2 This is also after 365bb2b4e, which uses `withFilter` rather than `filter`. thiz.withFilter(((check$q$1) => check$ifrefutable$1: @scala.unchecked match { case scala.Tuple2((k @ _), (v @ _)) => true case _ => false })).withFilter(((x$1) => x$1: @scala.unchecked match { case scala.Tuple2((k @ _), (v @ _)) => p(k, v).unary_$bang })).foreach(((x$2) => x$2: @scala.unchecked match { case scala.Tuple2((k @ _), (v @ _)) => thiz.$minus$eq(k) })); This commit does the same as `SetLike#retains`, and converts the map to an immutable list before the rest of the operation.
| * | SI-7814 Updates the instrumented version of ScalaRuntime.Jason Zaugg2013-09-051-24/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some tests for specialization use a modified version of the standard library that count boxing, array lookups etc. These sources are updated manually with the script: % test/instrumented/mkinstrumented.sh build Looks that that wasn't done for a while, though. This commit brings it up to date, and adjusts a few braces in ScalaRuntime.scala so the patch srt.scala (used by that script) is shorter. We should really avoid checking in the products of that script and run it as part of the build, or, better, use the bytecode instrumentation framework instead of a modified standard library. But I have to leave that for another day.
| * | SI-7814 Avoid init cycle between Predef, `package`, ScalaRuntimeJason Zaugg2013-09-051-11/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not every application will force these in a single thread; we have to do our best to avoid cycles between them. The enclosed test was failing every time before the change. This commit breaks the cycle by avoiding computing `tupleNames` in the constructor of `ScalaRuntime`. The new version has the added benefit of including specialized tuple subclasses, which is verified with a unit test for `isTuple`. Are there more of these lurking? It seems likely. I'm more than a little concerned about the way the `ControlThrowable` fires up `scala.SystemProperties` to check whether or not to suppress stack traces; there is already an ugly hack in place: object NoStackTrace { final def noSuppression = _noSuppression // two-stage init to make checkinit happy, // since sys.SystemProperties.noTraceSupression.value // calls back into NoStackTrace.noSuppression final private var _noSuppression = false _noSuppression = sys.SystemProperties.noTraceSupression.value }
* | Merge pull request #2865 from folone/trampolinesGrzegorz Kossakowski2013-09-071-9/+54
|\ \ | | | | | | Alter TailRec to have map and flatMap
| * | Stackless implementation of TailRec in constant memory.Runar Bjarnason2013-08-241-24/+34
| | |
| * | Alter TailRec to have map and flatMapGeorge Leontiev2013-08-241-7/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As described in the "Stackless Scala with Free Monads" paper scala> import scala.util.control.TailCalls._ import scala.util.control.TailCalls._ scala> :paste // Entering paste mode (ctrl-D to finish) def isEven(xs: List[Int]): TailRec[Boolean] = if (xs.isEmpty) done(true) else tailcall(isOdd(xs.tail)) def isOdd(xs: List[Int]): TailRec[Boolean] = if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail)) // Exiting paste mode, now interpreting. isEven: (xs: List[Int])util.control.TailCalls.TailRec[Boolean] isOdd: (xs: List[Int])util.control.TailCalls.TailRec[Boolean] scala> isEven((1 to 100000).toList).result res0: Boolean = true scala> def fib(n: Int): TailRec[Int] = | if (n < 2) done(n) else for { | x <- tailcall(fib(n - 1)) | y <- tailcall(fib(n - 2)) | } yield (x + y) fib: (n: Int)util.control.TailCalls.TailRec[Int] scala> fib(40).result res1: Int = 102334155
* | | Correcting scaladoc for all classes defining withDefaultValue method.nermin2013-08-304-4/+4
|/ / | | | | | | The description of the single parameter seems to be a copy and paste mistake from withDefault method.
* | Merge pull request #2867 from mmorearty/patch-1Adriaan Moors2013-08-231-1/+1
|\ \ | | | | | | Fix typo in sample code in scaladoc for package scala.sys.process
| * | Fix typo in sample code in scaladoc for package scala.sys.processMike Morearty2013-08-231-1/+1
| | |
* | | Merge pull request #2858 from Debilski/docstring-fixAdriaan Moors2013-08-231-1/+1
|\ \ \ | |/ / |/| | ProcessBuilder.lines(log) *does* throw an exception.
| * | ProcessBuilder.lines(log) *does* throw an exception.Rike-Benjamin Schuppner2013-08-201-1/+1
| | |
* | | Merge pull request #2810 from xeno-by/topic/compile-time-onlyAdriaan Moors2013-08-211-0/+22
|\ \ \ | |/ / |/| | @compileTimeOnly: moved to scala-library.jar, got some fixes
| * | moves compileTimeOnly to scala-libraryEugene Burmako2013-08-141-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is the notion that's come to be universally useful, so I suggest we promote it to be universally accessible. Note that the attached test incorrectly fails to report errors for definitions coming from the empty package and for annotations. These are bugs, and they are fixed in subsequent commits of this pull request.
* | | Add a helper method drop to ScalaRunTime.Paul Phillips2013-08-171-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | We should do a lot more of this - it's ridiculously difficult and error prone to generate code of this kind involving implicits, type inference, etc. where the same goal is trivially accomplished by generating a method call and letting the typer work out the details.
* | | Merge pull request #2803 from adriaanm/rebase-2728Adriaan Moors2013-08-161-18/+16
|\ \ \ | | | | | | | | SI-7658 Prevent StackOverflowError in ScalaRunTime.stringOf
| * | | Remove unused private[scala] def ScalaRunTime.checkZipSimon Ochsenreither2013-08-081-14/+0
| | | |