From 3d90e9d1fd4d0b40108b6bf0a64ee7353d001d52 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 3 Jan 2024 11:33:52 +0100 Subject: [PATCH 1/5] Revert "Move sources from `tests/pos-special/stdlib` to `scala2-library-cc`" This reverts commit 5c6e542817c347051281ae69a498a32fb17a900a. --- compiler/test/dotty/Properties.scala | 3 -- .../dotty/tools/dotc/CompilationTests.scala | 6 +-- .../stdlib}/collection/ArrayOps.scala | 21 ++++----- .../stdlib}/collection/BitSet.scala | 0 .../stdlib}/collection/BufferedIterator.scala | 0 .../stdlib}/collection/BuildFrom.scala | 2 +- .../stdlib}/collection/DefaultMap.scala | 0 .../stdlib}/collection/Factory.scala | 0 .../stdlib}/collection/Hashing.scala | 0 .../stdlib}/collection/IndexedSeq.scala | 18 +------- .../stdlib}/collection/IndexedSeqView.scala | 0 .../stdlib}/collection/Iterable.scala | 0 .../stdlib}/collection/IterableOnce.scala | 13 +++--- .../stdlib}/collection/Iterator.scala | 0 .../stdlib}/collection/JavaConverters.scala | 0 .../stdlib}/collection/LazyZipOps.scala | 0 .../stdlib}/collection/LinearSeq.scala | 0 .../pos-special/stdlib}/collection/Map.scala | 0 .../stdlib}/collection/MapView.scala | 2 +- .../stdlib}/collection/Searching.scala | 0 .../pos-special/stdlib}/collection/Seq.scala | 0 .../stdlib}/collection/SeqMap.scala | 0 .../stdlib}/collection/SeqView.scala | 0 .../pos-special/stdlib}/collection/Set.scala | 0 .../stdlib}/collection/SortedMap.scala | 0 .../stdlib}/collection/SortedOps.scala | 0 .../stdlib}/collection/SortedSet.scala | 1 + .../stdlib}/collection/Stepper.scala | 0 .../stdlib}/collection/StepperShape.scala | 0 .../StrictOptimizedIterableOps.scala | 0 .../collection/StrictOptimizedMapOps.scala | 0 .../collection/StrictOptimizedSeqOps.scala | 0 .../collection/StrictOptimizedSetOps.scala | 0 .../StrictOptimizedSortedMapOps.scala | 0 .../StrictOptimizedSortedSetOps.scala | 0 .../stdlib}/collection/StringOps.scala | 0 .../stdlib}/collection/StringParsers.scala | 5 ++ .../pos-special/stdlib}/collection/View.scala | 0 .../stdlib}/collection/WithFilter.scala | 0 .../collection/concurrent/BasicNode.java | 19 ++++++++ .../collection/concurrent/CNodeBase.java | 37 +++++++++++++++ .../stdlib/collection/concurrent/Gen.java | 15 ++++++ .../collection/concurrent/INodeBase.java | 39 ++++++++++++++++ .../collection/concurrent/MainNode.java | 46 +++++++++++++++++++ .../stdlib}/collection/concurrent/Map.scala | 0 .../collection/concurrent/TrieMap.scala | 0 .../collection/convert/AsJavaConverters.scala | 0 .../collection/convert/AsJavaExtensions.scala | 0 .../convert/AsScalaConverters.scala | 0 .../convert/AsScalaExtensions.scala | 0 .../convert/ImplicitConversions.scala | 0 .../convert/JavaCollectionWrappers.scala | 0 .../collection/convert/StreamExtensions.scala | 0 .../convert/impl/ArrayStepper.scala | 0 .../convert/impl/BinaryTreeStepper.scala | 0 .../convert/impl/BitSetStepper.scala | 0 .../convert/impl/ChampStepper.scala | 0 .../convert/impl/InOrderStepperBase.scala | 0 .../convert/impl/IndexedSeqStepper.scala | 0 .../convert/impl/IndexedStepperBase.scala | 0 .../convert/impl/IteratorStepper.scala | 0 .../convert/impl/NumericRangeStepper.scala | 0 .../convert/impl/RangeStepper.scala | 0 .../convert/impl/StringStepper.scala | 0 .../convert/impl/TableStepper.scala | 0 .../convert/impl/VectorStepper.scala | 0 .../collection/generic/BitOperations.scala | 0 .../generic/DefaultSerializationProxy.scala | 0 .../collection/generic/IsIterable.scala | 0 .../collection/generic/IsIterableOnce.scala | 0 .../stdlib}/collection/generic/IsMap.scala | 0 .../stdlib}/collection/generic/IsSeq.scala | 0 .../collection/generic/Subtractable.scala | 0 .../stdlib}/collection/generic/package.scala | 0 .../collection/immutable/ArraySeq.scala | 0 .../stdlib}/collection/immutable/BitSet.scala | 0 .../collection/immutable/ChampCommon.scala | 1 + .../collection/immutable/HashMap.scala | 0 .../collection/immutable/HashSet.scala | 0 .../stdlib}/collection/immutable/IntMap.scala | 0 .../collection/immutable/Iterable.scala | 0 .../immutable/LazyListIterable.scala | 0 .../stdlib}/collection/immutable/List.scala | 0 .../collection/immutable/ListMap.scala | 0 .../collection/immutable/ListSet.scala | 0 .../collection/immutable/LongMap.scala | 0 .../stdlib}/collection/immutable/Map.scala | 0 .../collection/immutable/NumericRange.scala | 0 .../stdlib}/collection/immutable/Queue.scala | 0 .../stdlib}/collection/immutable/Range.scala | 0 .../collection/immutable/RedBlackTree.scala | 0 .../stdlib}/collection/immutable/Seq.scala | 0 .../stdlib}/collection/immutable/SeqMap.scala | 0 .../stdlib}/collection/immutable/Set.scala | 0 .../collection/immutable/SortedMap.scala | 0 .../collection/immutable/SortedSet.scala | 0 .../immutable/StrictOptimizedSeqOps.scala | 0 .../collection/immutable/TreeMap.scala | 0 .../collection/immutable/TreeSeqMap.scala | 8 ++-- .../collection/immutable/TreeSet.scala | 0 .../stdlib}/collection/immutable/Vector.scala | 0 .../collection/immutable/VectorMap.scala | 0 .../collection/immutable/WrappedString.scala | 0 .../collection/immutable/package.scala | 0 .../collection/mutable/AnyRefMap.scala | 34 +++++++------- .../collection/mutable/ArrayBuffer.scala | 0 .../collection/mutable/ArrayBuilder.scala | 0 .../collection/mutable/ArrayDeque.scala | 0 .../stdlib}/collection/mutable/ArraySeq.scala | 0 .../stdlib}/collection/mutable/BitSet.scala | 0 .../stdlib}/collection/mutable/Buffer.scala | 1 + .../stdlib}/collection/mutable/Builder.scala | 0 .../mutable/CheckedIndexedSeqView.scala | 0 .../collection/mutable/Cloneable.scala | 0 .../mutable/CollisionProofHashMap.scala | 24 +++++----- .../stdlib}/collection/mutable/Growable.scala | 0 .../collection/mutable/GrowableBuilder.scala | 0 .../stdlib}/collection/mutable/HashMap.scala | 12 ++--- .../stdlib}/collection/mutable/HashSet.scala | 0 .../collection/mutable/HashTable.scala | 2 +- .../collection/mutable/ImmutableBuilder.scala | 0 .../collection/mutable/IndexedSeq.scala | 0 .../stdlib}/collection/mutable/Iterable.scala | 0 .../collection/mutable/LinkedHashMap.scala | 10 ++-- .../collection/mutable/LinkedHashSet.scala | 0 .../collection/mutable/ListBuffer.scala | 0 .../stdlib}/collection/mutable/ListMap.scala | 8 ++-- .../stdlib}/collection/mutable/LongMap.scala | 0 .../stdlib}/collection/mutable/Map.scala | 0 .../stdlib}/collection/mutable/MultiMap.scala | 2 +- .../collection/mutable/MutationTracker.scala | 0 .../collection/mutable/OpenHashMap.scala | 10 ++-- .../collection/mutable/PriorityQueue.scala | 0 .../stdlib}/collection/mutable/Queue.scala | 0 .../collection/mutable/RedBlackTree.scala | 28 +++++------ .../collection/mutable/ReusableBuilder.scala | 0 .../stdlib}/collection/mutable/Seq.scala | 0 .../stdlib}/collection/mutable/SeqMap.scala | 0 .../stdlib}/collection/mutable/Set.scala | 0 .../collection/mutable/Shrinkable.scala | 0 .../collection/mutable/SortedMap.scala | 0 .../collection/mutable/SortedSet.scala | 0 .../stdlib}/collection/mutable/Stack.scala | 0 .../collection/mutable/StringBuilder.scala | 0 .../stdlib}/collection/mutable/TreeMap.scala | 8 ++-- .../stdlib}/collection/mutable/TreeSet.scala | 0 .../collection/mutable/UnrolledBuffer.scala | 0 .../collection/mutable/WeakHashMap.scala | 8 ++-- .../stdlib}/collection/mutable/package.scala | 0 .../stdlib}/collection/package.scala | 0 .../stdlib}/runtime/PStatics.scala | 0 151 files changed, 264 insertions(+), 119 deletions(-) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/ArrayOps.scala (98%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/BitSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/BufferedIterator.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/BuildFrom.scala (99%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/DefaultMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/Factory.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/Hashing.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/IndexedSeq.scala (91%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/IndexedSeqView.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/Iterable.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/IterableOnce.scala (99%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/Iterator.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/JavaConverters.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/LazyZipOps.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/LinearSeq.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/Map.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/MapView.scala (98%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/Searching.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/Seq.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/SeqMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/SeqView.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/Set.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/SortedMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/SortedOps.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/SortedSet.scala (99%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/Stepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/StepperShape.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/StrictOptimizedIterableOps.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/StrictOptimizedMapOps.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/StrictOptimizedSeqOps.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/StrictOptimizedSetOps.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/StrictOptimizedSortedMapOps.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/StrictOptimizedSortedSetOps.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/StringOps.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/StringParsers.scala (99%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/View.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/WithFilter.scala (100%) create mode 100644 tests/pos-special/stdlib/collection/concurrent/BasicNode.java create mode 100644 tests/pos-special/stdlib/collection/concurrent/CNodeBase.java create mode 100644 tests/pos-special/stdlib/collection/concurrent/Gen.java create mode 100644 tests/pos-special/stdlib/collection/concurrent/INodeBase.java create mode 100644 tests/pos-special/stdlib/collection/concurrent/MainNode.java rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/concurrent/Map.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/concurrent/TrieMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/AsJavaConverters.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/AsJavaExtensions.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/AsScalaConverters.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/AsScalaExtensions.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/ImplicitConversions.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/JavaCollectionWrappers.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/StreamExtensions.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/ArrayStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/BinaryTreeStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/BitSetStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/ChampStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/InOrderStepperBase.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/IndexedSeqStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/IndexedStepperBase.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/IteratorStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/NumericRangeStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/RangeStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/StringStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/TableStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/convert/impl/VectorStepper.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/generic/BitOperations.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/generic/DefaultSerializationProxy.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/generic/IsIterable.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/generic/IsIterableOnce.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/generic/IsMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/generic/IsSeq.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/generic/Subtractable.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/generic/package.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/ArraySeq.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/BitSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/ChampCommon.scala (99%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/HashMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/HashSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/IntMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/Iterable.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/LazyListIterable.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/List.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/ListMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/ListSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/LongMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/Map.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/NumericRange.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/Queue.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/Range.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/RedBlackTree.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/Seq.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/SeqMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/Set.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/SortedMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/SortedSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/StrictOptimizedSeqOps.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/TreeMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/TreeSeqMap.scala (98%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/TreeSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/Vector.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/VectorMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/WrappedString.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/immutable/package.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/AnyRefMap.scala (91%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/ArrayBuffer.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/ArrayBuilder.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/ArrayDeque.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/ArraySeq.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/BitSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Buffer.scala (99%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Builder.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/CheckedIndexedSeqView.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Cloneable.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/CollisionProofHashMap.scala (95%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Growable.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/GrowableBuilder.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/HashMap.scala (97%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/HashSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/HashTable.scala (99%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/ImmutableBuilder.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/IndexedSeq.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Iterable.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/LinkedHashMap.scala (98%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/LinkedHashSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/ListBuffer.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/ListMap.scala (90%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/LongMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Map.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/MultiMap.scala (98%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/MutationTracker.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/OpenHashMap.scala (97%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/PriorityQueue.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Queue.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/RedBlackTree.scala (93%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/ReusableBuilder.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Seq.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/SeqMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Set.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Shrinkable.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/SortedMap.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/SortedSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/Stack.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/StringBuilder.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/TreeMap.scala (96%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/TreeSet.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/UnrolledBuffer.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/WeakHashMap.scala (83%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/mutable/package.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/collection/package.scala (100%) rename {scala2-library-cc/src/scala => tests/pos-special/stdlib}/runtime/PStatics.scala (100%) diff --git a/compiler/test/dotty/Properties.scala b/compiler/test/dotty/Properties.scala index e085b0de4875..4bb3628722ad 100644 --- a/compiler/test/dotty/Properties.scala +++ b/compiler/test/dotty/Properties.scala @@ -87,9 +87,6 @@ object Properties { /** If we are using the scala-library TASTy jar */ def usingScalaLibraryTasty: Boolean = scalaLibraryTasty.isDefined - /** If we are using the scala-library TASTy jar */ - - def usingScalaLibraryCCTasty: Boolean = scalaLibraryTasty.exists(_.contains("scala2-library-cc-tasty")) /** scala-asm jar */ def scalaAsm: String = sys.props("dotty.tests.classes.scalaAsm") diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 361712c2b469..798af9bdd6b5 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -45,9 +45,9 @@ class CompilationTests { compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)), compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")), ) ::: ( - // TODO create a folder for capture checking tests with the stdlib, or use tests/pos-custom-args/captures under this mode? - if Properties.usingScalaLibraryCCTasty then List(compileDir("tests/pos-special/stdlib", allowDeepSubtypes)) - else Nil + // FIXME: This fails due to a bug involving self types and capture checking + if Properties.usingScalaLibraryTasty then Nil + else List(compileDir("tests/pos-special/stdlib", allowDeepSubtypes)) ) if scala.util.Properties.isJavaAtLeast("16") then diff --git a/scala2-library-cc/src/scala/collection/ArrayOps.scala b/tests/pos-special/stdlib/collection/ArrayOps.scala similarity index 98% rename from scala2-library-cc/src/scala/collection/ArrayOps.scala rename to tests/pos-special/stdlib/collection/ArrayOps.scala index e8548c12751f..bb6174f59598 100644 --- a/scala2-library-cc/src/scala/collection/ArrayOps.scala +++ b/tests/pos-special/stdlib/collection/ArrayOps.scala @@ -113,7 +113,7 @@ object ArrayOps { b.result() } - def flatMap[BS, B](f: A => BS)(implicit asIterable: BS => Iterable[B], m: ClassTag[B]): Array[B] = + def flatMap[BS, B](f: A => BS)(implicit asIterable: BS => Iterable[B], m: ClassTag[B]): Array[B] = flatMap[B](x => asIterable(f(x))) /** Creates a new non-strict filter which combines this filter with the given predicate. */ @@ -505,7 +505,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal { * * @return a pair of arrays: the first one made of those values returned by `f` that were wrapped in [[scala.util.Left]], * and the second one made of those wrapped in [[scala.util.Right]]. */ - def partitionMap[A1: ClassTag, A2: ClassTag](f: A => Either[A1, A2]): (Array[A1], Array[A2]) = { + def partitionMap[A1: ClassTag, A2: ClassTag](f: A => Either[A1, A2]): (Array[A1], Array[A2]) = { val res1 = ArrayBuilder.make[A1] val res2 = ArrayBuilder.make[A2] var i = 0 @@ -816,7 +816,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal { * }}} * */ - def scanLeft[ B : ClassTag ](z: B)(op: (B, A) => B): Array[B] = { + def scanLeft[B : ClassTag](z: B)(op: (B, A) => B): Array[B] = { var v = z var i = 0 val res = new Array[B](xs.length + 1) @@ -855,7 +855,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal { * }}} * */ - def scanRight[ B : ClassTag ](z: B)(op: (A, B) => B): Array[B] = { + def scanRight[B : ClassTag](z: B)(op: (A, B) => B): Array[B] = { var v = z var i = xs.length - 1 val res = new Array[B](xs.length + 1) @@ -973,7 +973,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal { b.result() } - def flatMap[BS, B](f: A => BS)(implicit asIterable: BS => Iterable[B], m: ClassTag[B]): Array[B] = + def flatMap[BS, B](f: A => BS)(implicit asIterable: BS => Iterable[B], m: ClassTag[B]): Array[B] = flatMap[B](x => asIterable(f(x))) /** Flattens a two-dimensional array by concatenating all its rows @@ -1095,7 +1095,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal { * If this array is shorter than `that`, `thisElem` values are used to pad the result. * If `that` is shorter than this array, `thatElem` values are used to pad the result. */ - def zipAll[A1 >: A, B](that: Iterable[B], thisElem: A1, thatElem: B): Array[(A1, B)] = { + def zipAll[A1 >: A, B](that: Iterable[B], thisElem: A1, thatElem: B): Array[(A1, B)] = { val b = new ArrayBuilder.ofRef[(A1, B)]() val k = that.knownSize b.sizeHint(max(k, xs.length)) @@ -1244,7 +1244,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal { * @return a pair of Arrays, containing, respectively, the first and second half * of each element pair of this Array. */ - def unzip[A1, A2](implicit asPair: A => (A1, A2), ct1: ClassTag[A1], ct2: ClassTag[A2]): (Array[A1], Array[A2]) = { + def unzip[A1, A2](implicit asPair: A => (A1, A2), ct1: ClassTag[A1], ct2: ClassTag[A2]): (Array[A1], Array[A2]) = { val a1 = new Array[A1](xs.length) val a2 = new Array[A2](xs.length) var i = 0 @@ -1273,7 +1273,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal { * @return a triple of Arrays, containing, respectively, the first, second, and third * elements from each element triple of this Array. */ - def unzip3[A1, A2, A3](implicit asTriple: A => (A1, A2, A3), ct1: ClassTag[A1], ct2: ClassTag[A2], + def unzip3[A1, A2, A3](implicit asTriple: A => (A1, A2, A3), ct1: ClassTag[A1], ct2: ClassTag[A2], ct3: ClassTag[A3]): (Array[A1], Array[A2], Array[A3]) = { val a1 = new Array[A1](xs.length) val a2 = new Array[A2](xs.length) @@ -1418,7 +1418,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal { * @tparam K the type of keys returned by the discriminator function * @tparam B the type of values returned by the transformation function */ - def groupMap[K, B : ClassTag](key: A => K)(f: A => B): immutable.Map[K, Array[B]] = { + def groupMap[K, B : ClassTag](key: A => K)(f: A => B): immutable.Map[K, Array[B]] = { val m = mutable.Map.empty[K, ArrayBuilder[B]] val len = xs.length var i = 0 @@ -1479,8 +1479,7 @@ final class ArrayOps[A](private val xs: Array[A]) extends AnyVal { /** Create a copy of this array with the specified element type. */ def toArray[B >: A: ClassTag]: Array[B] = { val destination = new Array[B](xs.length) - @annotation.unused val copied = copyToArray(destination, 0) - //assert(copied == xs.length) + copyToArray(destination, 0) destination } diff --git a/scala2-library-cc/src/scala/collection/BitSet.scala b/tests/pos-special/stdlib/collection/BitSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/BitSet.scala rename to tests/pos-special/stdlib/collection/BitSet.scala diff --git a/scala2-library-cc/src/scala/collection/BufferedIterator.scala b/tests/pos-special/stdlib/collection/BufferedIterator.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/BufferedIterator.scala rename to tests/pos-special/stdlib/collection/BufferedIterator.scala diff --git a/scala2-library-cc/src/scala/collection/BuildFrom.scala b/tests/pos-special/stdlib/collection/BuildFrom.scala similarity index 99% rename from scala2-library-cc/src/scala/collection/BuildFrom.scala rename to tests/pos-special/stdlib/collection/BuildFrom.scala index d82e90777d3e..05df32856d82 100644 --- a/scala2-library-cc/src/scala/collection/BuildFrom.scala +++ b/tests/pos-special/stdlib/collection/BuildFrom.scala @@ -87,7 +87,7 @@ object BuildFrom extends BuildFromLowPriority1 { def newBuilder(from: Array[_]): Builder[A, Array[A]] = Factory.arrayFactory[A].newBuilder } - implicit def buildFromView[A, B]: BuildFrom[View[A], B, View[B]] = + implicit def buildFromView[A, B]: BuildFrom[View[A], B, View[B]] = new BuildFrom[View[A], B, View[B]] { def fromSpecific(from: View[A])(it: IterableOnce[B]^): View[B] = View.from(it).unsafeAssumePure def newBuilder(from: View[A]): Builder[B, View[B]] = View.newBuilder diff --git a/scala2-library-cc/src/scala/collection/DefaultMap.scala b/tests/pos-special/stdlib/collection/DefaultMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/DefaultMap.scala rename to tests/pos-special/stdlib/collection/DefaultMap.scala diff --git a/scala2-library-cc/src/scala/collection/Factory.scala b/tests/pos-special/stdlib/collection/Factory.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/Factory.scala rename to tests/pos-special/stdlib/collection/Factory.scala diff --git a/scala2-library-cc/src/scala/collection/Hashing.scala b/tests/pos-special/stdlib/collection/Hashing.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/Hashing.scala rename to tests/pos-special/stdlib/collection/Hashing.scala diff --git a/scala2-library-cc/src/scala/collection/IndexedSeq.scala b/tests/pos-special/stdlib/collection/IndexedSeq.scala similarity index 91% rename from scala2-library-cc/src/scala/collection/IndexedSeq.scala rename to tests/pos-special/stdlib/collection/IndexedSeq.scala index 998d1a5a635f..a2d4cc942231 100644 --- a/scala2-library-cc/src/scala/collection/IndexedSeq.scala +++ b/tests/pos-special/stdlib/collection/IndexedSeq.scala @@ -94,25 +94,11 @@ trait IndexedSeqOps[+A, +CC[_], +C] extends Any with IndexedSeqViewOps[A, CC, C] override def slice(from: Int, until: Int): C = fromSpecific(new IndexedSeqView.Slice(this, from, until)) - override def head: A = - if (!isEmpty) apply(0) - else throw new NoSuchElementException(s"head of empty ${ - self match { - case self: IndexedSeq[_] => self.collectionClassName - case _ => toString - } - }") + override def head: A = apply(0) override def headOption: Option[A] = if (isEmpty) None else Some(head) - override def last: A = - if (!isEmpty) apply(length - 1) - else throw new NoSuchElementException(s"last of empty ${ - self match { - case self: IndexedSeq[_] => self.collectionClassName - case _ => toString - } - }") + override def last: A = apply(length - 1) // We already inherit an efficient `lastOption = if (isEmpty) None else Some(last)` diff --git a/scala2-library-cc/src/scala/collection/IndexedSeqView.scala b/tests/pos-special/stdlib/collection/IndexedSeqView.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/IndexedSeqView.scala rename to tests/pos-special/stdlib/collection/IndexedSeqView.scala diff --git a/scala2-library-cc/src/scala/collection/Iterable.scala b/tests/pos-special/stdlib/collection/Iterable.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/Iterable.scala rename to tests/pos-special/stdlib/collection/Iterable.scala diff --git a/scala2-library-cc/src/scala/collection/IterableOnce.scala b/tests/pos-special/stdlib/collection/IterableOnce.scala similarity index 99% rename from scala2-library-cc/src/scala/collection/IterableOnce.scala rename to tests/pos-special/stdlib/collection/IterableOnce.scala index 30eb142ae156..a0b184410428 100644 --- a/scala2-library-cc/src/scala/collection/IterableOnce.scala +++ b/tests/pos-special/stdlib/collection/IterableOnce.scala @@ -19,7 +19,7 @@ import scala.collection.mutable.StringBuilder import scala.language.implicitConversions import scala.math.{Numeric, Ordering} import scala.reflect.ClassTag -import scala.runtime.{AbstractFunction1, AbstractFunction2} +import scala.runtime.AbstractFunction2 import language.experimental.captureChecking /** @@ -272,7 +272,7 @@ object IterableOnce { math.max(math.min(math.min(len, srcLen), destLen - start), 0) /** Calls `copyToArray` on the given collection, regardless of whether or not it is an `Iterable`. */ - @inline private[collection] def copyElemsToArray[A, B >: A]( + @inline private[collection] def copyElemsToArray[A, B >: A]( elems: IterableOnce[A]^, xs: Array[B], start: Int = 0, @@ -1117,8 +1117,8 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A]^ => def collectFirst[B](pf: PartialFunction[A, B]): Option[B] = { // Presumably the fastest way to get in and out of a partial function is for a sentinel function to return itself // (Tested to be lower-overhead than runWith. Would be better yet to not need to (formally) allocate it) - val sentinel: scala.Function1[A, Any] = new AbstractFunction1[A, Any] { - def apply(a: A): AbstractFunction1[A, Any] = this + val sentinel: scala.Function1[A, Any] = new scala.runtime.AbstractFunction1[A, Any] { + def apply(a: A) = this } val it = iterator while (it.hasNext) { @@ -1322,8 +1322,7 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A]^ => def toArray[B >: A: ClassTag]: Array[B] = if (knownSize >= 0) { val destination = new Array[B](knownSize) - @annotation.unused val copied = copyToArray(destination, 0) - //assert(copied == destination.length) + copyToArray(destination, 0) destination } else mutable.ArrayBuilder.make[B].addAll(this).result() @@ -1363,4 +1362,4 @@ object IterableOnceOps: m } } -end IterableOnceOps +end IterableOnceOps \ No newline at end of file diff --git a/scala2-library-cc/src/scala/collection/Iterator.scala b/tests/pos-special/stdlib/collection/Iterator.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/Iterator.scala rename to tests/pos-special/stdlib/collection/Iterator.scala diff --git a/scala2-library-cc/src/scala/collection/JavaConverters.scala b/tests/pos-special/stdlib/collection/JavaConverters.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/JavaConverters.scala rename to tests/pos-special/stdlib/collection/JavaConverters.scala diff --git a/scala2-library-cc/src/scala/collection/LazyZipOps.scala b/tests/pos-special/stdlib/collection/LazyZipOps.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/LazyZipOps.scala rename to tests/pos-special/stdlib/collection/LazyZipOps.scala diff --git a/scala2-library-cc/src/scala/collection/LinearSeq.scala b/tests/pos-special/stdlib/collection/LinearSeq.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/LinearSeq.scala rename to tests/pos-special/stdlib/collection/LinearSeq.scala diff --git a/scala2-library-cc/src/scala/collection/Map.scala b/tests/pos-special/stdlib/collection/Map.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/Map.scala rename to tests/pos-special/stdlib/collection/Map.scala diff --git a/scala2-library-cc/src/scala/collection/MapView.scala b/tests/pos-special/stdlib/collection/MapView.scala similarity index 98% rename from scala2-library-cc/src/scala/collection/MapView.scala rename to tests/pos-special/stdlib/collection/MapView.scala index 5909fe24fbbc..595fe20538d3 100644 --- a/scala2-library-cc/src/scala/collection/MapView.scala +++ b/tests/pos-special/stdlib/collection/MapView.scala @@ -161,7 +161,7 @@ object MapView extends MapViewFactory { override def isEmpty: Boolean = underlying.isEmpty } - override def newBuilder[X, Y]: Builder[(X, Y), MapView[X, Y]] = mutable.HashMap.newBuilder[X, Y].mapResult(_.view) + override def newBuilder[X, Y]: Builder[(X, Y), MapView[X, Y]] = mutable.HashMap.newBuilder[X, Y].mapResult(_.view) override def empty[K, V]: MapView[K, V] = EmptyMapView.asInstanceOf[MapView[K, V]] diff --git a/scala2-library-cc/src/scala/collection/Searching.scala b/tests/pos-special/stdlib/collection/Searching.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/Searching.scala rename to tests/pos-special/stdlib/collection/Searching.scala diff --git a/scala2-library-cc/src/scala/collection/Seq.scala b/tests/pos-special/stdlib/collection/Seq.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/Seq.scala rename to tests/pos-special/stdlib/collection/Seq.scala diff --git a/scala2-library-cc/src/scala/collection/SeqMap.scala b/tests/pos-special/stdlib/collection/SeqMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/SeqMap.scala rename to tests/pos-special/stdlib/collection/SeqMap.scala diff --git a/scala2-library-cc/src/scala/collection/SeqView.scala b/tests/pos-special/stdlib/collection/SeqView.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/SeqView.scala rename to tests/pos-special/stdlib/collection/SeqView.scala diff --git a/scala2-library-cc/src/scala/collection/Set.scala b/tests/pos-special/stdlib/collection/Set.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/Set.scala rename to tests/pos-special/stdlib/collection/Set.scala diff --git a/scala2-library-cc/src/scala/collection/SortedMap.scala b/tests/pos-special/stdlib/collection/SortedMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/SortedMap.scala rename to tests/pos-special/stdlib/collection/SortedMap.scala diff --git a/scala2-library-cc/src/scala/collection/SortedOps.scala b/tests/pos-special/stdlib/collection/SortedOps.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/SortedOps.scala rename to tests/pos-special/stdlib/collection/SortedOps.scala diff --git a/scala2-library-cc/src/scala/collection/SortedSet.scala b/tests/pos-special/stdlib/collection/SortedSet.scala similarity index 99% rename from scala2-library-cc/src/scala/collection/SortedSet.scala rename to tests/pos-special/stdlib/collection/SortedSet.scala index 639dc9ddead0..fb2f879edcd2 100644 --- a/scala2-library-cc/src/scala/collection/SortedSet.scala +++ b/tests/pos-special/stdlib/collection/SortedSet.scala @@ -69,6 +69,7 @@ trait SortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]] * @param start The lower-bound (inclusive) of the iterator */ def iteratorFrom(start: A): Iterator[A] + @deprecated("Use `iteratorFrom` instead.", "2.13.0") @`inline` def keysIteratorFrom(start: A): Iterator[A] = iteratorFrom(start) diff --git a/scala2-library-cc/src/scala/collection/Stepper.scala b/tests/pos-special/stdlib/collection/Stepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/Stepper.scala rename to tests/pos-special/stdlib/collection/Stepper.scala diff --git a/scala2-library-cc/src/scala/collection/StepperShape.scala b/tests/pos-special/stdlib/collection/StepperShape.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/StepperShape.scala rename to tests/pos-special/stdlib/collection/StepperShape.scala diff --git a/scala2-library-cc/src/scala/collection/StrictOptimizedIterableOps.scala b/tests/pos-special/stdlib/collection/StrictOptimizedIterableOps.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/StrictOptimizedIterableOps.scala rename to tests/pos-special/stdlib/collection/StrictOptimizedIterableOps.scala diff --git a/scala2-library-cc/src/scala/collection/StrictOptimizedMapOps.scala b/tests/pos-special/stdlib/collection/StrictOptimizedMapOps.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/StrictOptimizedMapOps.scala rename to tests/pos-special/stdlib/collection/StrictOptimizedMapOps.scala diff --git a/scala2-library-cc/src/scala/collection/StrictOptimizedSeqOps.scala b/tests/pos-special/stdlib/collection/StrictOptimizedSeqOps.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/StrictOptimizedSeqOps.scala rename to tests/pos-special/stdlib/collection/StrictOptimizedSeqOps.scala diff --git a/scala2-library-cc/src/scala/collection/StrictOptimizedSetOps.scala b/tests/pos-special/stdlib/collection/StrictOptimizedSetOps.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/StrictOptimizedSetOps.scala rename to tests/pos-special/stdlib/collection/StrictOptimizedSetOps.scala diff --git a/scala2-library-cc/src/scala/collection/StrictOptimizedSortedMapOps.scala b/tests/pos-special/stdlib/collection/StrictOptimizedSortedMapOps.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/StrictOptimizedSortedMapOps.scala rename to tests/pos-special/stdlib/collection/StrictOptimizedSortedMapOps.scala diff --git a/scala2-library-cc/src/scala/collection/StrictOptimizedSortedSetOps.scala b/tests/pos-special/stdlib/collection/StrictOptimizedSortedSetOps.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/StrictOptimizedSortedSetOps.scala rename to tests/pos-special/stdlib/collection/StrictOptimizedSortedSetOps.scala diff --git a/scala2-library-cc/src/scala/collection/StringOps.scala b/tests/pos-special/stdlib/collection/StringOps.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/StringOps.scala rename to tests/pos-special/stdlib/collection/StringOps.scala diff --git a/scala2-library-cc/src/scala/collection/StringParsers.scala b/tests/pos-special/stdlib/collection/StringParsers.scala similarity index 99% rename from scala2-library-cc/src/scala/collection/StringParsers.scala rename to tests/pos-special/stdlib/collection/StringParsers.scala index 75dedab7183c..47281815da71 100644 --- a/scala2-library-cc/src/scala/collection/StringParsers.scala +++ b/tests/pos-special/stdlib/collection/StringParsers.scala @@ -167,6 +167,7 @@ private[scala] object StringParsers { else None } } + //floating point final def checkFloatFormat(format: String): Boolean = { //indices are tracked with a start index which points *at* the first index @@ -193,6 +194,7 @@ private[scala] object StringParsers { rec(from) } + def isHexFloatLiteral(startIndex: Int, endIndex: Int): Boolean = { def isHexDigit(ch: Char) = ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || @@ -230,6 +232,7 @@ private[scala] object StringParsers { val pIndex = format.indexWhere(ch => ch == 'p' || ch == 'P', startIndex) (pIndex <= endIndex) && prefixOK(startIndex, pIndex) && postfixOK(pIndex + 1, endIndex) } + def isDecFloatLiteral(startIndex: Int, endIndex: Int): Boolean = { //invariant: endIndex > startIndex @@ -276,6 +279,7 @@ private[scala] object StringParsers { //count 0x00 to 0x20 as "whitespace", and nothing else val unspacedStart = format.indexWhere(ch => ch.toInt > 0x20) val unspacedEnd = format.lastIndexWhere(ch => ch.toInt > 0x20) + 1 + if (unspacedStart == -1 || unspacedStart >= unspacedEnd || unspacedEnd <= 0) false else { //all formats can have a sign @@ -302,6 +306,7 @@ private[scala] object StringParsers { } } } + @inline def parseFloat(from: String): Option[Float] = if (checkFloatFormat(from)) Some(java.lang.Float.parseFloat(from)) diff --git a/scala2-library-cc/src/scala/collection/View.scala b/tests/pos-special/stdlib/collection/View.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/View.scala rename to tests/pos-special/stdlib/collection/View.scala diff --git a/scala2-library-cc/src/scala/collection/WithFilter.scala b/tests/pos-special/stdlib/collection/WithFilter.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/WithFilter.scala rename to tests/pos-special/stdlib/collection/WithFilter.scala diff --git a/tests/pos-special/stdlib/collection/concurrent/BasicNode.java b/tests/pos-special/stdlib/collection/concurrent/BasicNode.java new file mode 100644 index 000000000000..c6ec91e4fde8 --- /dev/null +++ b/tests/pos-special/stdlib/collection/concurrent/BasicNode.java @@ -0,0 +1,19 @@ +/* + * Scala (https://www.scala-lang.org) + * + * Copyright EPFL and Lightbend, Inc. + * + * Licensed under Apache License 2.0 + * (http://www.apache.org/licenses/LICENSE-2.0). + * + * See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + */ + +package scala.collection.concurrent; + +public abstract class BasicNode { + + public abstract String string(int lev); + +} diff --git a/tests/pos-special/stdlib/collection/concurrent/CNodeBase.java b/tests/pos-special/stdlib/collection/concurrent/CNodeBase.java new file mode 100644 index 000000000000..ddffa365234e --- /dev/null +++ b/tests/pos-special/stdlib/collection/concurrent/CNodeBase.java @@ -0,0 +1,37 @@ +/* + * Scala (https://www.scala-lang.org) + * + * Copyright EPFL and Lightbend, Inc. + * + * Licensed under Apache License 2.0 + * (http://www.apache.org/licenses/LICENSE-2.0). + * + * See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + */ + +package scala.collection.concurrent; + +import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; + +abstract class CNodeBase extends MainNode { + + @SuppressWarnings("unchecked") + public static final AtomicIntegerFieldUpdater> updater = + AtomicIntegerFieldUpdater.newUpdater((Class>) (Class) CNodeBase.class, "csize"); + + public volatile int csize = -1; + + public boolean CAS_SIZE(int oldval, int nval) { + return updater.compareAndSet(this, oldval, nval); + } + + public void WRITE_SIZE(int nval) { + updater.set(this, nval); + } + + public int READ_SIZE() { + return updater.get(this); + } + +} diff --git a/tests/pos-special/stdlib/collection/concurrent/Gen.java b/tests/pos-special/stdlib/collection/concurrent/Gen.java new file mode 100644 index 000000000000..07af2983f32d --- /dev/null +++ b/tests/pos-special/stdlib/collection/concurrent/Gen.java @@ -0,0 +1,15 @@ +/* + * Scala (https://www.scala-lang.org) + * + * Copyright EPFL and Lightbend, Inc. + * + * Licensed under Apache License 2.0 + * (http://www.apache.org/licenses/LICENSE-2.0). + * + * See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + */ + +package scala.collection.concurrent; + +final class Gen {} diff --git a/tests/pos-special/stdlib/collection/concurrent/INodeBase.java b/tests/pos-special/stdlib/collection/concurrent/INodeBase.java new file mode 100644 index 000000000000..dfb99806594f --- /dev/null +++ b/tests/pos-special/stdlib/collection/concurrent/INodeBase.java @@ -0,0 +1,39 @@ +/* + * Scala (https://www.scala-lang.org) + * + * Copyright EPFL and Lightbend, Inc. + * + * Licensed under Apache License 2.0 + * (http://www.apache.org/licenses/LICENSE-2.0). + * + * See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + */ + +package scala.collection.concurrent; + +import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; + +abstract class INodeBase extends BasicNode { + + @SuppressWarnings("unchecked") + public static final AtomicReferenceFieldUpdater, MainNode> updater = + AtomicReferenceFieldUpdater.newUpdater((Class>) (Class) INodeBase.class, (Class>) (Class) MainNode.class, "mainnode"); + + static final Object RESTART = new Object(); + + static final Object NO_SUCH_ELEMENT_SENTINEL = new Object(); + + public volatile MainNode mainnode = null; + + public final Gen gen; + + public INodeBase(Gen generation) { + gen = generation; + } + + public BasicNode prev() { + return null; + } + +} diff --git a/tests/pos-special/stdlib/collection/concurrent/MainNode.java b/tests/pos-special/stdlib/collection/concurrent/MainNode.java new file mode 100644 index 000000000000..f7f022974e9e --- /dev/null +++ b/tests/pos-special/stdlib/collection/concurrent/MainNode.java @@ -0,0 +1,46 @@ +/* + * Scala (https://www.scala-lang.org) + * + * Copyright EPFL and Lightbend, Inc. + * + * Licensed under Apache License 2.0 + * (http://www.apache.org/licenses/LICENSE-2.0). + * + * See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + */ + +package scala.collection.concurrent; + +import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; + +abstract class MainNode extends BasicNode { + + @SuppressWarnings("unchecked") + public static final AtomicReferenceFieldUpdater, MainNode> updater = + AtomicReferenceFieldUpdater.newUpdater((Class>) (Class) MainNode.class, (Class>) (Class) MainNode.class, "prev"); + + public volatile MainNode prev = null; + + public abstract int cachedSize(Object ct); + + // standard contract + public abstract int knownSize(); + + public boolean CAS_PREV(MainNode oldval, MainNode nval) { + return updater.compareAndSet(this, oldval, nval); + } + + public void WRITE_PREV(MainNode nval) { + updater.set(this, nval); + } + + // do we need this? unclear in the javadocs... + // apparently not - volatile reads are supposed to be safe + // regardless of whether there are concurrent ARFU updates + @Deprecated @SuppressWarnings("unchecked") + public MainNode READ_PREV() { + return (MainNode) updater.get(this); + } + +} diff --git a/scala2-library-cc/src/scala/collection/concurrent/Map.scala b/tests/pos-special/stdlib/collection/concurrent/Map.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/concurrent/Map.scala rename to tests/pos-special/stdlib/collection/concurrent/Map.scala diff --git a/scala2-library-cc/src/scala/collection/concurrent/TrieMap.scala b/tests/pos-special/stdlib/collection/concurrent/TrieMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/concurrent/TrieMap.scala rename to tests/pos-special/stdlib/collection/concurrent/TrieMap.scala diff --git a/scala2-library-cc/src/scala/collection/convert/AsJavaConverters.scala b/tests/pos-special/stdlib/collection/convert/AsJavaConverters.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/AsJavaConverters.scala rename to tests/pos-special/stdlib/collection/convert/AsJavaConverters.scala diff --git a/scala2-library-cc/src/scala/collection/convert/AsJavaExtensions.scala b/tests/pos-special/stdlib/collection/convert/AsJavaExtensions.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/AsJavaExtensions.scala rename to tests/pos-special/stdlib/collection/convert/AsJavaExtensions.scala diff --git a/scala2-library-cc/src/scala/collection/convert/AsScalaConverters.scala b/tests/pos-special/stdlib/collection/convert/AsScalaConverters.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/AsScalaConverters.scala rename to tests/pos-special/stdlib/collection/convert/AsScalaConverters.scala diff --git a/scala2-library-cc/src/scala/collection/convert/AsScalaExtensions.scala b/tests/pos-special/stdlib/collection/convert/AsScalaExtensions.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/AsScalaExtensions.scala rename to tests/pos-special/stdlib/collection/convert/AsScalaExtensions.scala diff --git a/scala2-library-cc/src/scala/collection/convert/ImplicitConversions.scala b/tests/pos-special/stdlib/collection/convert/ImplicitConversions.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/ImplicitConversions.scala rename to tests/pos-special/stdlib/collection/convert/ImplicitConversions.scala diff --git a/scala2-library-cc/src/scala/collection/convert/JavaCollectionWrappers.scala b/tests/pos-special/stdlib/collection/convert/JavaCollectionWrappers.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/JavaCollectionWrappers.scala rename to tests/pos-special/stdlib/collection/convert/JavaCollectionWrappers.scala diff --git a/scala2-library-cc/src/scala/collection/convert/StreamExtensions.scala b/tests/pos-special/stdlib/collection/convert/StreamExtensions.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/StreamExtensions.scala rename to tests/pos-special/stdlib/collection/convert/StreamExtensions.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/ArrayStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/ArrayStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/ArrayStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/ArrayStepper.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/BinaryTreeStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/BinaryTreeStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/BinaryTreeStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/BinaryTreeStepper.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/BitSetStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/BitSetStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/BitSetStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/BitSetStepper.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/ChampStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/ChampStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/ChampStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/ChampStepper.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/InOrderStepperBase.scala b/tests/pos-special/stdlib/collection/convert/impl/InOrderStepperBase.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/InOrderStepperBase.scala rename to tests/pos-special/stdlib/collection/convert/impl/InOrderStepperBase.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/IndexedSeqStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/IndexedSeqStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/IndexedSeqStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/IndexedSeqStepper.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/IndexedStepperBase.scala b/tests/pos-special/stdlib/collection/convert/impl/IndexedStepperBase.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/IndexedStepperBase.scala rename to tests/pos-special/stdlib/collection/convert/impl/IndexedStepperBase.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/IteratorStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/IteratorStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/IteratorStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/IteratorStepper.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/NumericRangeStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/NumericRangeStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/NumericRangeStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/NumericRangeStepper.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/RangeStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/RangeStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/RangeStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/RangeStepper.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/StringStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/StringStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/StringStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/StringStepper.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/TableStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/TableStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/TableStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/TableStepper.scala diff --git a/scala2-library-cc/src/scala/collection/convert/impl/VectorStepper.scala b/tests/pos-special/stdlib/collection/convert/impl/VectorStepper.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/convert/impl/VectorStepper.scala rename to tests/pos-special/stdlib/collection/convert/impl/VectorStepper.scala diff --git a/scala2-library-cc/src/scala/collection/generic/BitOperations.scala b/tests/pos-special/stdlib/collection/generic/BitOperations.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/generic/BitOperations.scala rename to tests/pos-special/stdlib/collection/generic/BitOperations.scala diff --git a/scala2-library-cc/src/scala/collection/generic/DefaultSerializationProxy.scala b/tests/pos-special/stdlib/collection/generic/DefaultSerializationProxy.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/generic/DefaultSerializationProxy.scala rename to tests/pos-special/stdlib/collection/generic/DefaultSerializationProxy.scala diff --git a/scala2-library-cc/src/scala/collection/generic/IsIterable.scala b/tests/pos-special/stdlib/collection/generic/IsIterable.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/generic/IsIterable.scala rename to tests/pos-special/stdlib/collection/generic/IsIterable.scala diff --git a/scala2-library-cc/src/scala/collection/generic/IsIterableOnce.scala b/tests/pos-special/stdlib/collection/generic/IsIterableOnce.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/generic/IsIterableOnce.scala rename to tests/pos-special/stdlib/collection/generic/IsIterableOnce.scala diff --git a/scala2-library-cc/src/scala/collection/generic/IsMap.scala b/tests/pos-special/stdlib/collection/generic/IsMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/generic/IsMap.scala rename to tests/pos-special/stdlib/collection/generic/IsMap.scala diff --git a/scala2-library-cc/src/scala/collection/generic/IsSeq.scala b/tests/pos-special/stdlib/collection/generic/IsSeq.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/generic/IsSeq.scala rename to tests/pos-special/stdlib/collection/generic/IsSeq.scala diff --git a/scala2-library-cc/src/scala/collection/generic/Subtractable.scala b/tests/pos-special/stdlib/collection/generic/Subtractable.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/generic/Subtractable.scala rename to tests/pos-special/stdlib/collection/generic/Subtractable.scala diff --git a/scala2-library-cc/src/scala/collection/generic/package.scala b/tests/pos-special/stdlib/collection/generic/package.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/generic/package.scala rename to tests/pos-special/stdlib/collection/generic/package.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/ArraySeq.scala b/tests/pos-special/stdlib/collection/immutable/ArraySeq.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/ArraySeq.scala rename to tests/pos-special/stdlib/collection/immutable/ArraySeq.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/BitSet.scala b/tests/pos-special/stdlib/collection/immutable/BitSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/BitSet.scala rename to tests/pos-special/stdlib/collection/immutable/BitSet.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/ChampCommon.scala b/tests/pos-special/stdlib/collection/immutable/ChampCommon.scala similarity index 99% rename from scala2-library-cc/src/scala/collection/immutable/ChampCommon.scala rename to tests/pos-special/stdlib/collection/immutable/ChampCommon.scala index 3da269dccbd8..fc9bcb022874 100644 --- a/scala2-library-cc/src/scala/collection/immutable/ChampCommon.scala +++ b/tests/pos-special/stdlib/collection/immutable/ChampCommon.scala @@ -113,6 +113,7 @@ private[immutable] abstract class ChampBaseIterator[T <: Node[T]] { // ChampBaseReverseIterator and in convert.impl.ChampStepperBase. // If you change this code, check those also in case they also // need to be modified. + protected var currentValueCursor: Int = 0 protected var currentValueLength: Int = 0 protected var currentValueNode: T = _ diff --git a/scala2-library-cc/src/scala/collection/immutable/HashMap.scala b/tests/pos-special/stdlib/collection/immutable/HashMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/HashMap.scala rename to tests/pos-special/stdlib/collection/immutable/HashMap.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/HashSet.scala b/tests/pos-special/stdlib/collection/immutable/HashSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/HashSet.scala rename to tests/pos-special/stdlib/collection/immutable/HashSet.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/IntMap.scala b/tests/pos-special/stdlib/collection/immutable/IntMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/IntMap.scala rename to tests/pos-special/stdlib/collection/immutable/IntMap.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/Iterable.scala b/tests/pos-special/stdlib/collection/immutable/Iterable.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/Iterable.scala rename to tests/pos-special/stdlib/collection/immutable/Iterable.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/LazyListIterable.scala b/tests/pos-special/stdlib/collection/immutable/LazyListIterable.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/LazyListIterable.scala rename to tests/pos-special/stdlib/collection/immutable/LazyListIterable.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/List.scala b/tests/pos-special/stdlib/collection/immutable/List.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/List.scala rename to tests/pos-special/stdlib/collection/immutable/List.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/ListMap.scala b/tests/pos-special/stdlib/collection/immutable/ListMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/ListMap.scala rename to tests/pos-special/stdlib/collection/immutable/ListMap.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/ListSet.scala b/tests/pos-special/stdlib/collection/immutable/ListSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/ListSet.scala rename to tests/pos-special/stdlib/collection/immutable/ListSet.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/LongMap.scala b/tests/pos-special/stdlib/collection/immutable/LongMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/LongMap.scala rename to tests/pos-special/stdlib/collection/immutable/LongMap.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/Map.scala b/tests/pos-special/stdlib/collection/immutable/Map.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/Map.scala rename to tests/pos-special/stdlib/collection/immutable/Map.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/NumericRange.scala b/tests/pos-special/stdlib/collection/immutable/NumericRange.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/NumericRange.scala rename to tests/pos-special/stdlib/collection/immutable/NumericRange.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/Queue.scala b/tests/pos-special/stdlib/collection/immutable/Queue.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/Queue.scala rename to tests/pos-special/stdlib/collection/immutable/Queue.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/Range.scala b/tests/pos-special/stdlib/collection/immutable/Range.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/Range.scala rename to tests/pos-special/stdlib/collection/immutable/Range.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/RedBlackTree.scala b/tests/pos-special/stdlib/collection/immutable/RedBlackTree.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/RedBlackTree.scala rename to tests/pos-special/stdlib/collection/immutable/RedBlackTree.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/Seq.scala b/tests/pos-special/stdlib/collection/immutable/Seq.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/Seq.scala rename to tests/pos-special/stdlib/collection/immutable/Seq.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/SeqMap.scala b/tests/pos-special/stdlib/collection/immutable/SeqMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/SeqMap.scala rename to tests/pos-special/stdlib/collection/immutable/SeqMap.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/Set.scala b/tests/pos-special/stdlib/collection/immutable/Set.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/Set.scala rename to tests/pos-special/stdlib/collection/immutable/Set.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/SortedMap.scala b/tests/pos-special/stdlib/collection/immutable/SortedMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/SortedMap.scala rename to tests/pos-special/stdlib/collection/immutable/SortedMap.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/SortedSet.scala b/tests/pos-special/stdlib/collection/immutable/SortedSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/SortedSet.scala rename to tests/pos-special/stdlib/collection/immutable/SortedSet.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/StrictOptimizedSeqOps.scala b/tests/pos-special/stdlib/collection/immutable/StrictOptimizedSeqOps.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/StrictOptimizedSeqOps.scala rename to tests/pos-special/stdlib/collection/immutable/StrictOptimizedSeqOps.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/TreeMap.scala b/tests/pos-special/stdlib/collection/immutable/TreeMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/TreeMap.scala rename to tests/pos-special/stdlib/collection/immutable/TreeMap.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/TreeSeqMap.scala b/tests/pos-special/stdlib/collection/immutable/TreeSeqMap.scala similarity index 98% rename from scala2-library-cc/src/scala/collection/immutable/TreeSeqMap.scala rename to tests/pos-special/stdlib/collection/immutable/TreeSeqMap.scala index dc59d21b8b19..fe194fa9de5a 100644 --- a/scala2-library-cc/src/scala/collection/immutable/TreeSeqMap.scala +++ b/tests/pos-special/stdlib/collection/immutable/TreeSeqMap.scala @@ -303,7 +303,7 @@ object TreeSeqMap extends MapFactory[TreeSeqMap] { else EmptyByInsertion }.asInstanceOf[TreeSeqMap[K, V]] - def from[K, V](it: collection.IterableOnce[(K, V)]^): TreeSeqMap[K, V] = + def from[K, V](it: collection.IterableOnce[(K, V)]^): TreeSeqMap[K, V] = it match { case om: TreeSeqMap[K, V] => om case _ => (newBuilder[K, V] ++= it).result() @@ -311,10 +311,10 @@ object TreeSeqMap extends MapFactory[TreeSeqMap] { @inline private def increment(ord: Int) = if (ord == Int.MaxValue) Int.MinValue else ord + 1 - def newBuilder[K, V]: mutable.Builder[(K, V), TreeSeqMap[K, V]] = newBuilder(OrderBy.Insertion) - def newBuilder[K, V](orderedBy: OrderBy): mutable.Builder[(K, V), TreeSeqMap[K, V]] = new Builder[K, V](orderedBy) + def newBuilder[K, V]: mutable.Builder[(K, V), TreeSeqMap[K, V]] = newBuilder(OrderBy.Insertion) + def newBuilder[K, V](orderedBy: OrderBy): mutable.Builder[(K, V), TreeSeqMap[K, V]] = new Builder[K, V](orderedBy) - final class Builder[K, V](orderedBy: OrderBy) extends mutable.Builder[(K, V), TreeSeqMap[K, V]] { + final class Builder[K, V](orderedBy: OrderBy) extends mutable.Builder[(K, V), TreeSeqMap[K, V]] { private[this] val bdr = new MapBuilderImpl[K, (Int, V)] private[this] var ong = Ordering.empty[K] private[this] var ord = 0 diff --git a/scala2-library-cc/src/scala/collection/immutable/TreeSet.scala b/tests/pos-special/stdlib/collection/immutable/TreeSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/TreeSet.scala rename to tests/pos-special/stdlib/collection/immutable/TreeSet.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/Vector.scala b/tests/pos-special/stdlib/collection/immutable/Vector.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/Vector.scala rename to tests/pos-special/stdlib/collection/immutable/Vector.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/VectorMap.scala b/tests/pos-special/stdlib/collection/immutable/VectorMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/VectorMap.scala rename to tests/pos-special/stdlib/collection/immutable/VectorMap.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/WrappedString.scala b/tests/pos-special/stdlib/collection/immutable/WrappedString.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/WrappedString.scala rename to tests/pos-special/stdlib/collection/immutable/WrappedString.scala diff --git a/scala2-library-cc/src/scala/collection/immutable/package.scala b/tests/pos-special/stdlib/collection/immutable/package.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/immutable/package.scala rename to tests/pos-special/stdlib/collection/immutable/package.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/AnyRefMap.scala b/tests/pos-special/stdlib/collection/mutable/AnyRefMap.scala similarity index 91% rename from scala2-library-cc/src/scala/collection/mutable/AnyRefMap.scala rename to tests/pos-special/stdlib/collection/mutable/AnyRefMap.scala index 480babbf4b91..8f1ac07e725e 100644 --- a/scala2-library-cc/src/scala/collection/mutable/AnyRefMap.scala +++ b/tests/pos-special/stdlib/collection/mutable/AnyRefMap.scala @@ -43,7 +43,7 @@ import language.experimental.captureChecking * rapidly as 2^30^ is approached. * */ -class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K -> V, initialBufferSize: Int, initBlank: Boolean) +class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K -> V, initialBufferSize: Int, initBlank: Boolean) extends AbstractMap[K, V] with MapOps[K, V, Map, AnyRefMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, AnyRefMap[K, V]] @@ -478,11 +478,11 @@ class AnyRefMap[K <: AnyRef, V] private[collection] (defaultEntry: K -> V, initi } // The implicit dummy parameter is necessary to distinguish these methods from the base methods they overload (not override) - def map[K2 <: AnyRef, V2](f: ((K, V)) => (K2, V2))(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] = + def map[K2 <: AnyRef, V2](f: ((K, V)) => (K2, V2))(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] = AnyRefMap.from(new View.Map(this, f)) - def flatMap[K2 <: AnyRef, V2](f: ((K, V)) => IterableOnce[(K2, V2)])(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] = + def flatMap[K2 <: AnyRef, V2](f: ((K, V)) => IterableOnce[(K2, V2)])(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] = AnyRefMap.from(new View.FlatMap(this, f)) - def collect[K2 <: AnyRef, V2](pf: PartialFunction[(K, V), (K2, V2)])(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] = + def collect[K2 <: AnyRef, V2](pf: PartialFunction[(K, V), (K2, V2)])(implicit dummy: DummyImplicit): AnyRefMap[K2, V2] = strictOptimizedCollect(AnyRefMap.newBuilder[K2, V2], pf) override def clear(): Unit = { @@ -515,7 +515,7 @@ object AnyRefMap { * * This builder can be reused to create multiple instances. */ - final class AnyRefMapBuilder[K <: AnyRef, V] extends ReusableBuilder[(K, V), AnyRefMap[K, V]] { + final class AnyRefMapBuilder[K <: AnyRef, V] extends ReusableBuilder[(K, V), AnyRefMap[K, V]] { private[collection] var elems: AnyRefMap[K, V] = new AnyRefMap[K, V] def addOne(entry: (K, V)): this.type = { elems += entry @@ -527,11 +527,11 @@ object AnyRefMap { } /** Creates a new `AnyRefMap` with zero or more key/value pairs. */ - def apply[K <: AnyRef, V](elems: (K, V)*): AnyRefMap[K, V] = buildFromIterableOnce(elems) + def apply[K <: AnyRef, V](elems: (K, V)*): AnyRefMap[K, V] = buildFromIterableOnce(elems) - def newBuilder[K <: AnyRef, V]: ReusableBuilder[(K, V), AnyRefMap[K, V]] = new AnyRefMapBuilder[K, V] + def newBuilder[K <: AnyRef, V]: ReusableBuilder[(K, V), AnyRefMap[K, V]] = new AnyRefMapBuilder[K, V] - private def buildFromIterableOnce[K <: AnyRef, V](elems: IterableOnce[(K, V)]^): AnyRefMap[K, V] = { + private def buildFromIterableOnce[K <: AnyRef, V](elems: IterableOnce[(K, V)]^): AnyRefMap[K, V] = { var sz = elems.knownSize if(sz < 0) sz = 4 val arm = new AnyRefMap[K, V](sz * 2) @@ -541,10 +541,10 @@ object AnyRefMap { } /** Creates a new empty `AnyRefMap`. */ - def empty[K <: AnyRef, V]: AnyRefMap[K, V] = new AnyRefMap[K, V] + 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) + def withDefault[K <: AnyRef, V](default: K -> V): AnyRefMap[K, V] = new AnyRefMap[K, V](default) /** Creates a new `AnyRefMap` from an existing source collection. A source collection * which is already an `AnyRefMap` gets cloned. @@ -554,7 +554,7 @@ object AnyRefMap { * @tparam V the type of the values * @return a new `AnyRefMap` with the elements of `source` */ - def from[K <: AnyRef, V](source: IterableOnce[(K, V)]^): AnyRefMap[K, V] = source match { + def from[K <: AnyRef, V](source: IterableOnce[(K, V)]^): AnyRefMap[K, V] = source match { case source: AnyRefMap[_, _] => source.clone().asInstanceOf[AnyRefMap[K, V]] case _ => buildFromIterableOnce(source) } @@ -562,7 +562,7 @@ object AnyRefMap { /** 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] = { + def fromZip[K <: AnyRef, V](keys: Array[K], values: Array[V]): AnyRefMap[K, V] = { val sz = math.min(keys.length, values.length) val arm = new AnyRefMap[K, V](sz * 2) var i = 0 @@ -574,7 +574,7 @@ object AnyRefMap { /** 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] = { + def fromZip[K <: AnyRef, V](keys: Iterable[K]^, values: Iterable[V]^): AnyRefMap[K, V] = { val sz = math.min(keys.size, values.size) val arm = new AnyRefMap[K, V](sz * 2) val ki = keys.iterator @@ -584,7 +584,7 @@ object AnyRefMap { arm } - implicit def toFactory[K <: AnyRef, V](dummy: AnyRefMap.type): Factory[(K, V), AnyRefMap[K, V]] = ToFactory.asInstanceOf[Factory[(K, V), AnyRefMap[K, V]]] + implicit def toFactory[K <: AnyRef, V](dummy: AnyRefMap.type): Factory[(K, V), AnyRefMap[K, V]] = ToFactory.asInstanceOf[Factory[(K, V), AnyRefMap[K, V]]] @SerialVersionUID(3L) private[this] object ToFactory extends Factory[(AnyRef, AnyRef), AnyRefMap[AnyRef, AnyRef]] with Serializable { @@ -592,12 +592,12 @@ object AnyRefMap { def newBuilder: Builder[(AnyRef, AnyRef), AnyRefMap[AnyRef, AnyRef]] = AnyRefMap.newBuilder[AnyRef, AnyRef] } - implicit def toBuildFrom[K <: AnyRef, V](factory: AnyRefMap.type): BuildFrom[Any, (K, V), AnyRefMap[K, V]] = ToBuildFrom.asInstanceOf[BuildFrom[Any, (K, V), AnyRefMap[K, V]]] + implicit def toBuildFrom[K <: AnyRef, V](factory: AnyRefMap.type): BuildFrom[Any, (K, V), AnyRefMap[K, V]] = ToBuildFrom.asInstanceOf[BuildFrom[Any, (K, V), AnyRefMap[K, V]]] private[this] object ToBuildFrom extends BuildFrom[Any, (AnyRef, AnyRef), AnyRefMap[AnyRef, AnyRef]] { def fromSpecific(from: Any)(it: IterableOnce[(AnyRef, AnyRef)]^) = AnyRefMap.from(it) def newBuilder(from: Any) = AnyRefMap.newBuilder[AnyRef, AnyRef] } - implicit def iterableFactory[K <: AnyRef, V]: Factory[(K, V), AnyRefMap[K, V]] = toFactory[K, V](this) - implicit def buildFromAnyRefMap[K <: AnyRef, V]: BuildFrom[AnyRefMap[_, _], (K, V), AnyRefMap[K, V]] = toBuildFrom(this) + implicit def iterableFactory[K <: AnyRef, V]: Factory[(K, V), AnyRefMap[K, V]] = toFactory[K, V](this) + implicit def buildFromAnyRefMap[K <: AnyRef, V]: BuildFrom[AnyRefMap[_, _], (K, V), AnyRefMap[K, V]] = toBuildFrom(this) } diff --git a/scala2-library-cc/src/scala/collection/mutable/ArrayBuffer.scala b/tests/pos-special/stdlib/collection/mutable/ArrayBuffer.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/ArrayBuffer.scala rename to tests/pos-special/stdlib/collection/mutable/ArrayBuffer.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/ArrayBuilder.scala b/tests/pos-special/stdlib/collection/mutable/ArrayBuilder.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/ArrayBuilder.scala rename to tests/pos-special/stdlib/collection/mutable/ArrayBuilder.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/ArrayDeque.scala b/tests/pos-special/stdlib/collection/mutable/ArrayDeque.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/ArrayDeque.scala rename to tests/pos-special/stdlib/collection/mutable/ArrayDeque.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/ArraySeq.scala b/tests/pos-special/stdlib/collection/mutable/ArraySeq.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/ArraySeq.scala rename to tests/pos-special/stdlib/collection/mutable/ArraySeq.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/BitSet.scala b/tests/pos-special/stdlib/collection/mutable/BitSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/BitSet.scala rename to tests/pos-special/stdlib/collection/mutable/BitSet.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/Buffer.scala b/tests/pos-special/stdlib/collection/mutable/Buffer.scala similarity index 99% rename from scala2-library-cc/src/scala/collection/mutable/Buffer.scala rename to tests/pos-special/stdlib/collection/mutable/Buffer.scala index f9aa9cf28c72..1f7fc76972a2 100644 --- a/scala2-library-cc/src/scala/collection/mutable/Buffer.scala +++ b/tests/pos-special/stdlib/collection/mutable/Buffer.scala @@ -104,6 +104,7 @@ trait Buffer[A] @throws[IndexOutOfBoundsException] @throws[IllegalArgumentException] def remove(idx: Int, count: Int): Unit + /** Removes a single element from this buffer, at its first occurrence. * If the buffer does not contain that element, it is unchanged. * diff --git a/scala2-library-cc/src/scala/collection/mutable/Builder.scala b/tests/pos-special/stdlib/collection/mutable/Builder.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/Builder.scala rename to tests/pos-special/stdlib/collection/mutable/Builder.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/CheckedIndexedSeqView.scala b/tests/pos-special/stdlib/collection/mutable/CheckedIndexedSeqView.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/CheckedIndexedSeqView.scala rename to tests/pos-special/stdlib/collection/mutable/CheckedIndexedSeqView.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/Cloneable.scala b/tests/pos-special/stdlib/collection/mutable/Cloneable.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/Cloneable.scala rename to tests/pos-special/stdlib/collection/mutable/Cloneable.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/CollisionProofHashMap.scala b/tests/pos-special/stdlib/collection/mutable/CollisionProofHashMap.scala similarity index 95% rename from scala2-library-cc/src/scala/collection/mutable/CollisionProofHashMap.scala rename to tests/pos-special/stdlib/collection/mutable/CollisionProofHashMap.scala index ff3bab1dd818..0679ab7be201 100644 --- a/scala2-library-cc/src/scala/collection/mutable/CollisionProofHashMap.scala +++ b/tests/pos-special/stdlib/collection/mutable/CollisionProofHashMap.scala @@ -33,7 +33,7 @@ import language.experimental.captureChecking * @define mayNotTerminateInf * @define willNotTerminateInf */ -final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double)(implicit ordering: Ordering[K]) +final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double)(implicit ordering: Ordering[K]) extends AbstractMap[K, V] with MapOps[K, V, Map, CollisionProofHashMap[K, V]] //-- with StrictOptimizedIterableOps[(K, V), Iterable, CollisionProofHashMap[K, V]] @@ -744,17 +744,17 @@ final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double object CollisionProofHashMap extends SortedMapFactory[CollisionProofHashMap] { private[collection] final val ordMsg = "No implicit Ordering[${K2}] found to build a CollisionProofHashMap[${K2}, ${V2}]. You may want to upcast to a Map[${K}, ${V}] first by calling `unsorted`." - def from[K : Ordering, V](it: scala.collection.IterableOnce[(K, V)]^): CollisionProofHashMap[K, V] = { + def from[K : Ordering, V](it: scala.collection.IterableOnce[(K, V)]^): CollisionProofHashMap[K, V] = { val k = it.knownSize val cap = if(k > 0) ((k + 1).toDouble / defaultLoadFactor).toInt else defaultInitialCapacity new CollisionProofHashMap[K, V](cap, defaultLoadFactor) ++= it } - def empty[K : Ordering, V]: CollisionProofHashMap[K, V] = new CollisionProofHashMap[K, V] + def empty[K : Ordering, V]: CollisionProofHashMap[K, V] = new CollisionProofHashMap[K, V] - def newBuilder[K : Ordering, V]: Builder[(K, V), CollisionProofHashMap[K, V]] = newBuilder(defaultInitialCapacity, defaultLoadFactor) + def newBuilder[K : Ordering, V]: Builder[(K, V), CollisionProofHashMap[K, V]] = newBuilder(defaultInitialCapacity, defaultLoadFactor) - def newBuilder[K : Ordering, V](initialCapacity: Int, loadFactor: Double): Builder[(K, V), CollisionProofHashMap[K, V]] = + def newBuilder[K : Ordering, V](initialCapacity: Int, loadFactor: Double): Builder[(K, V), CollisionProofHashMap[K, V]] = new GrowableBuilder[(K, V), CollisionProofHashMap[K, V]](new CollisionProofHashMap[K, V](initialCapacity, loadFactor)) { override def sizeHint(size: Int) = elems.sizeHint(size) } @@ -766,7 +766,7 @@ object CollisionProofHashMap extends SortedMapFactory[CollisionProofHashMap] { final def defaultInitialCapacity: Int = 16 @SerialVersionUID(3L) - private final class DeserializationFactory[K, V](val tableLength: Int, val loadFactor: Double, val ordering: Ordering[K]) extends Factory[(K, V), CollisionProofHashMap[K, V]] with Serializable { + private final class DeserializationFactory[K, V](val tableLength: Int, val loadFactor: Double, val ordering: Ordering[K]) extends Factory[(K, V), CollisionProofHashMap[K, V]] with Serializable { def fromSpecific(it: IterableOnce[(K, V)]^): CollisionProofHashMap[K, V] = new CollisionProofHashMap[K, V](tableLength, loadFactor)(ordering) ++= it def newBuilder: Builder[(K, V), CollisionProofHashMap[K, V]] = CollisionProofHashMap.newBuilder(tableLength, loadFactor)(ordering) } @@ -789,7 +789,7 @@ object CollisionProofHashMap extends SortedMapFactory[CollisionProofHashMap] { /////////////////////////// Red-Black Tree Node - final class RBNode[K, V](var key: K, var hash: Int, var value: V, var red: Boolean, var left: RBNode[K, V], var right: RBNode[K, V], var parent: RBNode[K, V]) extends Node { + final class RBNode[K, V](var key: K, var hash: Int, var value: V, var red: Boolean, var left: RBNode[K, V], var right: RBNode[K, V], var parent: RBNode[K, V]) extends Node { override def toString: String = "RBNode(" + key + ", " + hash + ", " + value + ", " + red + ", " + left + ", " + right + ")" @tailrec def getNode(k: K, h: Int)(implicit ord: Ordering[K]): RBNode[K, V] = { @@ -820,17 +820,17 @@ object CollisionProofHashMap extends SortedMapFactory[CollisionProofHashMap] { } } - @`inline` private def leaf[A, B](key: A, hash: Int, value: B, red: Boolean, parent: RBNode[A, B]): RBNode[A, B] = + @`inline` private def leaf[A, B](key: A, hash: Int, value: B, red: Boolean, parent: RBNode[A, B]): RBNode[A, B] = new RBNode(key, hash, value, red, null, null, parent) - @tailrec private def minNodeNonNull[A, B](node: RBNode[A, B]): RBNode[A, B] = + @tailrec private def minNodeNonNull[A, B](node: RBNode[A, B]): RBNode[A, B] = if (node.left eq null) node else minNodeNonNull(node.left) /** * Returns the node that follows `node` in an in-order tree traversal. If `node` has the maximum key (and is, * therefore, the last node), this method returns `null`. */ - private def successor[A, B](node: RBNode[A, B]): RBNode[A, B] = { + private def successor[A, B](node: RBNode[A, B]): RBNode[A, B] = { if (node.right ne null) minNodeNonNull(node.right) else { var x = node @@ -843,7 +843,7 @@ object CollisionProofHashMap extends SortedMapFactory[CollisionProofHashMap] { } } - private final class RBNodesIterator[A, B](tree: RBNode[A, B])(implicit @unused ord: Ordering[A]) extends AbstractIterator[RBNode[A, B]] { + private final class RBNodesIterator[A, B](tree: RBNode[A, B])(implicit @unused ord: Ordering[A]) extends AbstractIterator[RBNode[A, B]] { private[this] var nextNode: RBNode[A, B] = if(tree eq null) null else minNodeNonNull(tree) def hasNext: Boolean = nextNode ne null @@ -859,7 +859,7 @@ object CollisionProofHashMap extends SortedMapFactory[CollisionProofHashMap] { /////////////////////////// Linked List Node - private final class LLNode[K, V](var key: K, var hash: Int, var value: V, var next: LLNode[K, V]) extends Node { + private final class LLNode[K, V](var key: K, var hash: Int, var value: V, var next: LLNode[K, V]) extends Node { override def toString = s"LLNode($key, $value, $hash) -> $next" private[this] def eq(a: Any, b: Any): Boolean = diff --git a/scala2-library-cc/src/scala/collection/mutable/Growable.scala b/tests/pos-special/stdlib/collection/mutable/Growable.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/Growable.scala rename to tests/pos-special/stdlib/collection/mutable/Growable.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/GrowableBuilder.scala b/tests/pos-special/stdlib/collection/mutable/GrowableBuilder.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/GrowableBuilder.scala rename to tests/pos-special/stdlib/collection/mutable/GrowableBuilder.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/HashMap.scala b/tests/pos-special/stdlib/collection/mutable/HashMap.scala similarity index 97% rename from scala2-library-cc/src/scala/collection/mutable/HashMap.scala rename to tests/pos-special/stdlib/collection/mutable/HashMap.scala index 89a9f3f186f7..1ba651b47819 100644 --- a/scala2-library-cc/src/scala/collection/mutable/HashMap.scala +++ b/tests/pos-special/stdlib/collection/mutable/HashMap.scala @@ -33,7 +33,7 @@ import language.experimental.captureChecking * @define willNotTerminateInf */ @deprecatedInheritance("HashMap will be made final; use .withDefault for the common use case of computing a default value", "2.13.0") -class HashMap[K, V](initialCapacity: Int, loadFactor: Double) +class HashMap[K, V](initialCapacity: Int, loadFactor: Double) extends AbstractMap[K, V] with MapOps[K, V, HashMap, HashMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, HashMap[K, V]] @@ -597,17 +597,17 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double) @SerialVersionUID(3L) object HashMap extends MapFactory[HashMap] { - def empty[K, V]: HashMap[K, V] = new HashMap[K, V] + def empty[K, V]: HashMap[K, V] = new HashMap[K, V] - def from[K, V](it: collection.IterableOnce[(K, V)]^): HashMap[K, V] = { + def from[K, V](it: collection.IterableOnce[(K, V)]^): HashMap[K, V] = { val k = it.knownSize val cap = if(k > 0) ((k + 1).toDouble / defaultLoadFactor).toInt else defaultInitialCapacity new HashMap[K, V](cap, defaultLoadFactor).addAll(it) } - def newBuilder[K, V]: Builder[(K, V), HashMap[K, V]] = newBuilder(defaultInitialCapacity, defaultLoadFactor) + def newBuilder[K, V]: Builder[(K, V), HashMap[K, V]] = newBuilder(defaultInitialCapacity, defaultLoadFactor) - def newBuilder[K, V](initialCapacity: Int, loadFactor: Double): Builder[(K, V), HashMap[K, V]] = + def newBuilder[K, V](initialCapacity: Int, loadFactor: Double): Builder[(K, V), HashMap[K, V]] = new GrowableBuilder[(K, V), HashMap[K, V]](new HashMap[K, V](initialCapacity, loadFactor)) { override def sizeHint(size: Int) = elems.sizeHint(size) } @@ -619,7 +619,7 @@ object HashMap extends MapFactory[HashMap] { final def defaultInitialCapacity: Int = 16 @SerialVersionUID(3L) - private final class DeserializationFactory[K, V](val tableLength: Int, val loadFactor: Double) extends Factory[(K, V), HashMap[K, V]] with Serializable { + private final class DeserializationFactory[K, V](val tableLength: Int, val loadFactor: Double) extends Factory[(K, V), HashMap[K, V]] with Serializable { def fromSpecific(it: IterableOnce[(K, V)]^): HashMap[K, V] = new HashMap[K, V](tableLength, loadFactor).addAll(it) def newBuilder: Builder[(K, V), HashMap[K, V]] = HashMap.newBuilder(tableLength, loadFactor) } diff --git a/scala2-library-cc/src/scala/collection/mutable/HashSet.scala b/tests/pos-special/stdlib/collection/mutable/HashSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/HashSet.scala rename to tests/pos-special/stdlib/collection/mutable/HashSet.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/HashTable.scala b/tests/pos-special/stdlib/collection/mutable/HashTable.scala similarity index 99% rename from scala2-library-cc/src/scala/collection/mutable/HashTable.scala rename to tests/pos-special/stdlib/collection/mutable/HashTable.scala index 461df6cea22c..64af941eac1f 100644 --- a/scala2-library-cc/src/scala/collection/mutable/HashTable.scala +++ b/tests/pos-special/stdlib/collection/mutable/HashTable.scala @@ -412,7 +412,7 @@ private[collection] object HashTable { /** Class used internally. */ -private[collection] trait HashEntry[A, E <: HashEntry[A, E]] { +private[collection] trait HashEntry[A, E <: HashEntry[A, E]] { val key: A var next: E = _ } diff --git a/scala2-library-cc/src/scala/collection/mutable/ImmutableBuilder.scala b/tests/pos-special/stdlib/collection/mutable/ImmutableBuilder.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/ImmutableBuilder.scala rename to tests/pos-special/stdlib/collection/mutable/ImmutableBuilder.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/IndexedSeq.scala b/tests/pos-special/stdlib/collection/mutable/IndexedSeq.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/IndexedSeq.scala rename to tests/pos-special/stdlib/collection/mutable/IndexedSeq.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/Iterable.scala b/tests/pos-special/stdlib/collection/mutable/Iterable.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/Iterable.scala rename to tests/pos-special/stdlib/collection/mutable/Iterable.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/LinkedHashMap.scala b/tests/pos-special/stdlib/collection/mutable/LinkedHashMap.scala similarity index 98% rename from scala2-library-cc/src/scala/collection/mutable/LinkedHashMap.scala rename to tests/pos-special/stdlib/collection/mutable/LinkedHashMap.scala index e3fc9d6aefd6..528c39e49bdf 100644 --- a/scala2-library-cc/src/scala/collection/mutable/LinkedHashMap.scala +++ b/tests/pos-special/stdlib/collection/mutable/LinkedHashMap.scala @@ -34,7 +34,7 @@ import language.experimental.captureChecking * @define orderDependentFold */ @deprecatedInheritance("LinkedHashMap will be made final; use .withDefault for the common use case of computing a default value", "2.13.11") -class LinkedHashMap[K, V] +class LinkedHashMap[K, V] extends AbstractMap[K, V] with SeqMap[K, V] with MapOps[K, V, LinkedHashMap, LinkedHashMap[K, V]] @@ -477,20 +477,20 @@ class LinkedHashMap[K, V] @SerialVersionUID(3L) object LinkedHashMap extends MapFactory[LinkedHashMap] { - def empty[K, V] = new LinkedHashMap[K, V] + def empty[K, V] = new LinkedHashMap[K, V] - def from[K, V](it: collection.IterableOnce[(K, V)]^) = { + def from[K, V](it: collection.IterableOnce[(K, V)]^) = { val newlhm = empty[K, V] newlhm.sizeHint(it.knownSize) newlhm.addAll(it) newlhm } - def newBuilder[K, V] = new GrowableBuilder(empty[K, V]) + def newBuilder[K, V] = new GrowableBuilder(empty[K, V]) /** Class for the linked hash map entry, used internally. */ - private[mutable] final class LinkedEntry[K, V](val key: K, val hash: Int, var value: V) { + private[mutable] final class LinkedEntry[K, V](val key: K, val hash: Int, var value: V) { var earlier: LinkedEntry[K, V] = null var later: LinkedEntry[K, V] = null var next: LinkedEntry[K, V] = null diff --git a/scala2-library-cc/src/scala/collection/mutable/LinkedHashSet.scala b/tests/pos-special/stdlib/collection/mutable/LinkedHashSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/LinkedHashSet.scala rename to tests/pos-special/stdlib/collection/mutable/LinkedHashSet.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/ListBuffer.scala b/tests/pos-special/stdlib/collection/mutable/ListBuffer.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/ListBuffer.scala rename to tests/pos-special/stdlib/collection/mutable/ListBuffer.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/ListMap.scala b/tests/pos-special/stdlib/collection/mutable/ListMap.scala similarity index 90% rename from scala2-library-cc/src/scala/collection/mutable/ListMap.scala rename to tests/pos-special/stdlib/collection/mutable/ListMap.scala index 26e904e271a1..e4f9322050d5 100644 --- a/scala2-library-cc/src/scala/collection/mutable/ListMap.scala +++ b/tests/pos-special/stdlib/collection/mutable/ListMap.scala @@ -31,7 +31,7 @@ import language.experimental.captureChecking * @define orderDependentFold */ @deprecated("Use an immutable.ListMap assigned to a var instead of mutable.ListMap", "2.13.0") -class ListMap[K, V] +class ListMap[K, V] extends AbstractMap[K, V] with MapOps[K, V, ListMap, ListMap[K, V]] with StrictOptimizedIterableOps[(K, V), Iterable, ListMap[K, V]] @@ -77,7 +77,7 @@ class ListMap[K, V] @SerialVersionUID(3L) @deprecated("Use an immutable.ListMap assigned to a var instead of mutable.ListMap", "2.13.0") object ListMap extends MapFactory[ListMap] { - def empty[K, V]: ListMap[K, V] = new ListMap[K, V] - def from[K, V](it: IterableOnce[(K, V)]^): ListMap[K,V] = Growable.from(empty[K, V], it) - def newBuilder[K, V]: Builder[(K, V), ListMap[K,V]] = new GrowableBuilder(empty[K, V]) + def empty[K, V]: ListMap[K, V] = new ListMap[K, V] + def from[K, V](it: IterableOnce[(K, V)]^): ListMap[K,V] = Growable.from(empty[K, V], it) + def newBuilder[K, V]: Builder[(K, V), ListMap[K,V]] = new GrowableBuilder(empty[K, V]) } diff --git a/scala2-library-cc/src/scala/collection/mutable/LongMap.scala b/tests/pos-special/stdlib/collection/mutable/LongMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/LongMap.scala rename to tests/pos-special/stdlib/collection/mutable/LongMap.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/Map.scala b/tests/pos-special/stdlib/collection/mutable/Map.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/Map.scala rename to tests/pos-special/stdlib/collection/mutable/Map.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/MultiMap.scala b/tests/pos-special/stdlib/collection/mutable/MultiMap.scala similarity index 98% rename from scala2-library-cc/src/scala/collection/mutable/MultiMap.scala rename to tests/pos-special/stdlib/collection/mutable/MultiMap.scala index 0b250a5548ef..93b0d6ae4d73 100644 --- a/scala2-library-cc/src/scala/collection/mutable/MultiMap.scala +++ b/tests/pos-special/stdlib/collection/mutable/MultiMap.scala @@ -52,7 +52,7 @@ import language.experimental.captureChecking * @define Coll `MultiMap` */ @deprecated("Use a scala.collection.mutable.MultiDict in the scala-collection-contrib module", "2.13.0") -trait MultiMap[K, V] extends Map[K, Set[V]] { +trait MultiMap[K, V] extends Map[K, Set[V]] { /** Creates a new set. * * Classes that use this trait as a mixin can override this method diff --git a/scala2-library-cc/src/scala/collection/mutable/MutationTracker.scala b/tests/pos-special/stdlib/collection/mutable/MutationTracker.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/MutationTracker.scala rename to tests/pos-special/stdlib/collection/mutable/MutationTracker.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/OpenHashMap.scala b/tests/pos-special/stdlib/collection/mutable/OpenHashMap.scala similarity index 97% rename from scala2-library-cc/src/scala/collection/mutable/OpenHashMap.scala rename to tests/pos-special/stdlib/collection/mutable/OpenHashMap.scala index d29be3ffea5e..978245d5bffb 100644 --- a/scala2-library-cc/src/scala/collection/mutable/OpenHashMap.scala +++ b/tests/pos-special/stdlib/collection/mutable/OpenHashMap.scala @@ -26,10 +26,10 @@ import language.experimental.captureChecking @SerialVersionUID(3L) object OpenHashMap extends MapFactory[OpenHashMap] { - def empty[K, V] = new OpenHashMap[K, V] - def from[K, V](it: IterableOnce[(K, V)]^): OpenHashMap[K,V] = empty ++= it + def empty[K, V] = new OpenHashMap[K, V] + def from[K, V](it: IterableOnce[(K, V)]^): OpenHashMap[K,V] = empty ++= it - def newBuilder[K, V]: Builder[(K, V), OpenHashMap[K,V]] = + def newBuilder[K, V]: Builder[(K, V), OpenHashMap[K,V]] = new GrowableBuilder[(K, V), OpenHashMap[K, V]](empty) /** A hash table entry. @@ -39,7 +39,7 @@ object OpenHashMap extends MapFactory[OpenHashMap] { * If its `key` is not the default value of type `Key`, the entry is occupied. * If the entry is occupied, `hash` contains the hash value of `key`. */ - final private class OpenEntry[Key, Value](var key: Key, + final private class OpenEntry[Key, Value](var key: Key, var hash: Int, var value: Option[Value]) @@ -62,7 +62,7 @@ object OpenHashMap extends MapFactory[OpenHashMap] { * @define willNotTerminateInf */ @deprecated("Use HashMap or one of the specialized versions (LongMap, AnyRefMap) instead of OpenHashMap", "2.13.0") -class OpenHashMap[Key, Value](initialSize : Int) +class OpenHashMap[Key, Value](initialSize : Int) extends AbstractMap[Key, Value] with MapOps[Key, Value, OpenHashMap, OpenHashMap[Key, Value]] with StrictOptimizedIterableOps[(Key, Value), Iterable, OpenHashMap[Key, Value]] diff --git a/scala2-library-cc/src/scala/collection/mutable/PriorityQueue.scala b/tests/pos-special/stdlib/collection/mutable/PriorityQueue.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/PriorityQueue.scala rename to tests/pos-special/stdlib/collection/mutable/PriorityQueue.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/Queue.scala b/tests/pos-special/stdlib/collection/mutable/Queue.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/Queue.scala rename to tests/pos-special/stdlib/collection/mutable/Queue.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/RedBlackTree.scala b/tests/pos-special/stdlib/collection/mutable/RedBlackTree.scala similarity index 93% rename from scala2-library-cc/src/scala/collection/mutable/RedBlackTree.scala rename to tests/pos-special/stdlib/collection/mutable/RedBlackTree.scala index f808a4257eef..4e079bca3245 100644 --- a/scala2-library-cc/src/scala/collection/mutable/RedBlackTree.scala +++ b/tests/pos-special/stdlib/collection/mutable/RedBlackTree.scala @@ -32,25 +32,25 @@ private[collection] object RedBlackTree { // Therefore, while obtaining the size of the whole tree is O(1), knowing the number of entries inside a range is O(n) // on the size of the range. - final class Tree[A, B](var root: Node[A, B], var size: Int) { + final class Tree[A, B](var root: Node[A, B], var size: Int) { def treeCopy(): Tree[A, B] = new Tree(copyTree(root), size) } - final class Node[A, B](var key: A, var value: B, var red: Boolean, var left: Node[A, B], var right: Node[A, B], var parent: Node[A, B]) { + final class Node[A, B](var key: A, var value: B, var red: Boolean, var left: Node[A, B], var right: Node[A, B], var parent: Node[A, B]) { override def toString: String = "Node(" + key + ", " + value + ", " + red + ", " + left + ", " + right + ")" } object Tree { - def empty[A, B]: Tree[A, B] = new Tree(null, 0) + def empty[A, B]: Tree[A, B] = new Tree(null, 0) } object Node { - @`inline` def apply[A, B](key: A, value: B, red: Boolean, + @`inline` def apply[A, B](key: A, value: B, red: Boolean, left: Node[A, B], right: Node[A, B], parent: Node[A, B]): Node[A, B] = new Node(key, value, red, left, right, parent) - @`inline` def leaf[A, B](key: A, value: B, red: Boolean, parent: Node[A, B]): Node[A, B] = + @`inline` def leaf[A, B](key: A, value: B, red: Boolean, parent: Node[A, B]): Node[A, B] = new Node(key, value, red, null, null, parent) def unapply[A, B](t: Node[A, B]) = Some((t.key, t.value, t.left, t.right, t.parent)) @@ -181,7 +181,7 @@ private[collection] object RedBlackTree { // ---- insertion ---- - def insert[A, B](tree: Tree[A, B], key: A, value: B)(implicit ord: Ordering[A]): Unit = { + def insert[A, B](tree: Tree[A, B], key: A, value: B)(implicit ord: Ordering[A]): Unit = { var y: Node[A, B] = null var x = tree.root var cmp = 1 @@ -477,16 +477,16 @@ private[collection] object RedBlackTree { if (node.right ne null) transformNodeNonNull(node.right, f) } - def iterator[A: Ordering, B](tree: Tree[A, B], start: Option[A] = None, end: Option[A] = None): Iterator[(A, B)] = + def iterator[A: Ordering, B](tree: Tree[A, B], start: Option[A] = None, end: Option[A] = None): Iterator[(A, B)] = new EntriesIterator(tree, start, end) def keysIterator[A: Ordering](tree: Tree[A, _], start: Option[A] = None, end: Option[A] = None): Iterator[A] = new KeysIterator(tree, start, end) - def valuesIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A] = None, end: Option[A] = None): Iterator[B] = + def valuesIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A] = None, end: Option[A] = None): Iterator[B] = new ValuesIterator(tree, start, end) - private[this] abstract class TreeIterator[A, B, R](tree: Tree[A, B], start: Option[A], end: Option[A]) + private[this] abstract class TreeIterator[A, B, R](tree: Tree[A, B], start: Option[A], end: Option[A]) (implicit ord: Ordering[A]) extends AbstractIterator[R] { protected def nextResult(node: Node[A, B]): R @@ -514,19 +514,19 @@ private[collection] object RedBlackTree { setNullIfAfterEnd() } - private[this] final class EntriesIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A], end: Option[A]) + private[this] final class EntriesIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A], end: Option[A]) extends TreeIterator[A, B, (A, B)](tree, start, end) { def nextResult(node: Node[A, B]) = (node.key, node.value) } - private[this] final class KeysIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A], end: Option[A]) + private[this] final class KeysIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A], end: Option[A]) extends TreeIterator[A, B, A](tree, start, end) { def nextResult(node: Node[A, B]) = node.key } - private[this] final class ValuesIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A], end: Option[A]) + private[this] final class ValuesIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A], end: Option[A]) extends TreeIterator[A, B, B](tree, start, end) { def nextResult(node: Node[A, B]) = node.value @@ -623,7 +623,7 @@ private[collection] object RedBlackTree { } /** Build a Tree suitable for a TreeMap from an ordered sequence of key/value pairs */ - def fromOrderedEntries[A, B](xs: Iterator[(A, B)], size: Int): Tree[A, B] = { + def fromOrderedEntries[A, B](xs: Iterator[(A, B)], size: Int): Tree[A, B] = { val maxUsedDepth = 32 - Integer.numberOfLeadingZeros(size) // maximum depth of non-leaf nodes def f(level: Int, size: Int): Node[A, B] = size match { case 0 => null @@ -643,7 +643,7 @@ private[collection] object RedBlackTree { new Tree(f(1, size), size) } - def copyTree[A, B](n: Node[A, B]): Node[A, B] = + def copyTree[A, B](n: Node[A, B]): Node[A, B] = if(n eq null) null else { val c = new Node(n.key, n.value, n.red, copyTree(n.left), copyTree(n.right), null) if(c.left != null) c.left.parent = c diff --git a/scala2-library-cc/src/scala/collection/mutable/ReusableBuilder.scala b/tests/pos-special/stdlib/collection/mutable/ReusableBuilder.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/ReusableBuilder.scala rename to tests/pos-special/stdlib/collection/mutable/ReusableBuilder.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/Seq.scala b/tests/pos-special/stdlib/collection/mutable/Seq.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/Seq.scala rename to tests/pos-special/stdlib/collection/mutable/Seq.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/SeqMap.scala b/tests/pos-special/stdlib/collection/mutable/SeqMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/SeqMap.scala rename to tests/pos-special/stdlib/collection/mutable/SeqMap.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/Set.scala b/tests/pos-special/stdlib/collection/mutable/Set.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/Set.scala rename to tests/pos-special/stdlib/collection/mutable/Set.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/Shrinkable.scala b/tests/pos-special/stdlib/collection/mutable/Shrinkable.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/Shrinkable.scala rename to tests/pos-special/stdlib/collection/mutable/Shrinkable.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/SortedMap.scala b/tests/pos-special/stdlib/collection/mutable/SortedMap.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/SortedMap.scala rename to tests/pos-special/stdlib/collection/mutable/SortedMap.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/SortedSet.scala b/tests/pos-special/stdlib/collection/mutable/SortedSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/SortedSet.scala rename to tests/pos-special/stdlib/collection/mutable/SortedSet.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/Stack.scala b/tests/pos-special/stdlib/collection/mutable/Stack.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/Stack.scala rename to tests/pos-special/stdlib/collection/mutable/Stack.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/StringBuilder.scala b/tests/pos-special/stdlib/collection/mutable/StringBuilder.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/StringBuilder.scala rename to tests/pos-special/stdlib/collection/mutable/StringBuilder.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/TreeMap.scala b/tests/pos-special/stdlib/collection/mutable/TreeMap.scala similarity index 96% rename from scala2-library-cc/src/scala/collection/mutable/TreeMap.scala rename to tests/pos-special/stdlib/collection/mutable/TreeMap.scala index d36e1b9d207d..dbb87a950d74 100644 --- a/scala2-library-cc/src/scala/collection/mutable/TreeMap.scala +++ b/tests/pos-special/stdlib/collection/mutable/TreeMap.scala @@ -29,7 +29,7 @@ import language.experimental.captureChecking * @define Coll mutable.TreeMap * @define coll mutable tree map */ -sealed class TreeMap[K, V] private (tree: RB.Tree[K, V])(implicit val ordering: Ordering[K]) +sealed class TreeMap[K, V] private (tree: RB.Tree[K, V])(implicit val ordering: Ordering[K]) extends AbstractMap[K, V] with SortedMap[K, V] with SortedMapOps[K, V, TreeMap, TreeMap[K, V]] @@ -248,11 +248,11 @@ sealed class TreeMap[K, V] private (tree: RB.Tree[K, V])(implicit val ordering: @SerialVersionUID(3L) object TreeMap extends SortedMapFactory[TreeMap] { - def from[K : Ordering, V](it: IterableOnce[(K, V)]^): TreeMap[K, V] = + def from[K : Ordering, V](it: IterableOnce[(K, V)]^): TreeMap[K, V] = Growable.from(empty[K, V], it) - def empty[K : Ordering, V]: TreeMap[K, V] = new TreeMap[K, V]() + def empty[K : Ordering, V]: TreeMap[K, V] = new TreeMap[K, V]() - def newBuilder[K: Ordering, V]: Builder[(K, V), TreeMap[K, V]] = new GrowableBuilder(empty[K, V]) + def newBuilder[K: Ordering, V]: Builder[(K, V), TreeMap[K, V]] = new GrowableBuilder(empty[K, V]) } diff --git a/scala2-library-cc/src/scala/collection/mutable/TreeSet.scala b/tests/pos-special/stdlib/collection/mutable/TreeSet.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/TreeSet.scala rename to tests/pos-special/stdlib/collection/mutable/TreeSet.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/UnrolledBuffer.scala b/tests/pos-special/stdlib/collection/mutable/UnrolledBuffer.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/UnrolledBuffer.scala rename to tests/pos-special/stdlib/collection/mutable/UnrolledBuffer.scala diff --git a/scala2-library-cc/src/scala/collection/mutable/WeakHashMap.scala b/tests/pos-special/stdlib/collection/mutable/WeakHashMap.scala similarity index 83% rename from scala2-library-cc/src/scala/collection/mutable/WeakHashMap.scala rename to tests/pos-special/stdlib/collection/mutable/WeakHashMap.scala index 1ccd36c3e25f..1f94281a0b59 100644 --- a/scala2-library-cc/src/scala/collection/mutable/WeakHashMap.scala +++ b/tests/pos-special/stdlib/collection/mutable/WeakHashMap.scala @@ -34,7 +34,7 @@ import language.experimental.captureChecking * @define willNotTerminateInf */ @SerialVersionUID(3L) -class WeakHashMap[K, V] extends JMapWrapper[K, V](new java.util.WeakHashMap) +class WeakHashMap[K, V] extends JMapWrapper[K, V](new java.util.WeakHashMap) with JMapWrapperLike[K, V, WeakHashMap, WeakHashMap[K, V]] with MapFactoryDefaults[K, V, WeakHashMap, Iterable] { override def empty = new WeakHashMap[K, V] @@ -49,8 +49,8 @@ class WeakHashMap[K, V] extends JMapWrapper[K, V](new java.util.WeakHashMap) */ @SerialVersionUID(3L) object WeakHashMap extends MapFactory[WeakHashMap] { - def empty[K, V]: WeakHashMap[K,V] = new WeakHashMap[K, V] - def from[K, V](it: collection.IterableOnce[(K, V)]^): WeakHashMap[K,V] = Growable.from(empty[K, V], it) - def newBuilder[K, V]: Builder[(K, V), WeakHashMap[K,V]] = new GrowableBuilder(WeakHashMap.empty[K, V]) + def empty[K, V]: WeakHashMap[K,V] = new WeakHashMap[K, V] + def from[K, V](it: collection.IterableOnce[(K, V)]^): WeakHashMap[K,V] = Growable.from(empty[K, V], it) + def newBuilder[K, V]: Builder[(K, V), WeakHashMap[K,V]] = new GrowableBuilder(WeakHashMap.empty[K, V]) } diff --git a/scala2-library-cc/src/scala/collection/mutable/package.scala b/tests/pos-special/stdlib/collection/mutable/package.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/mutable/package.scala rename to tests/pos-special/stdlib/collection/mutable/package.scala diff --git a/scala2-library-cc/src/scala/collection/package.scala b/tests/pos-special/stdlib/collection/package.scala similarity index 100% rename from scala2-library-cc/src/scala/collection/package.scala rename to tests/pos-special/stdlib/collection/package.scala diff --git a/scala2-library-cc/src/scala/runtime/PStatics.scala b/tests/pos-special/stdlib/runtime/PStatics.scala similarity index 100% rename from scala2-library-cc/src/scala/runtime/PStatics.scala rename to tests/pos-special/stdlib/runtime/PStatics.scala From b0f55ae184ce35cae567314d7fcd85b978a74ccd Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 3 Jan 2024 11:41:05 +0100 Subject: [PATCH 2/5] Revert "Patch self type of Function1 and PartialFunction" This reverts commit d0c481763c408de33b1736dc5e5b223e4e8c5fef. --- scala2-library-cc/src/scala/Function1.scala | 90 ---- .../src/scala/PartialFunction.scala | 403 ------------------ scala2-library-cc/src/scala/TODO | 1 - 3 files changed, 494 deletions(-) delete mode 100644 scala2-library-cc/src/scala/Function1.scala delete mode 100644 scala2-library-cc/src/scala/PartialFunction.scala delete mode 100644 scala2-library-cc/src/scala/TODO diff --git a/scala2-library-cc/src/scala/Function1.scala b/scala2-library-cc/src/scala/Function1.scala deleted file mode 100644 index 96ca493739ed..000000000000 --- a/scala2-library-cc/src/scala/Function1.scala +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Scala (https://www.scala-lang.org) - * - * Copyright EPFL and Lightbend, Inc. - * - * Licensed under Apache License 2.0 - * (http://www.apache.org/licenses/LICENSE-2.0). - * - * See the NOTICE file distributed with this work for - * additional information regarding copyright ownership. - */ - -// GENERATED CODE: DO NOT EDIT. See scala.Function0 for timestamp. - -package scala - - -object Function1 { - - implicit final class UnliftOps[A, B] private[Function1](private val f: A => Option[B]) extends AnyVal { - /** Converts an optional function to a partial function. - * - * @example Unlike [[Function.unlift]], this [[UnliftOps.unlift]] method can be used in extractors. - * {{{ - * val of: Int => Option[String] = { i => - * if (i == 2) { - * Some("matched by an optional function") - * } else { - * None - * } - * } - * - * util.Random.nextInt(4) match { - * case of.unlift(m) => // Convert an optional function to a pattern - * println(m) - * case _ => - * println("Not matched") - * } - * }}} - */ - def unlift: PartialFunction[A, B] = Function.unlift(f) - } - -} - -/** A function of 1 parameter. - * - * In the following example, the definition of `succ` is - * shorthand, conceptually, for the anonymous class definition - * `anonfun1`, although the implementation details of how the - * function value is constructed may differ: - * - * {{{ - * object Main extends App { - * val succ = (x: Int) => x + 1 - * val anonfun1 = new Function1[Int, Int] { - * def apply(x: Int): Int = x + 1 - * } - * assert(succ(0) == anonfun1(0)) - * } - * }}} - * - * Note that the difference between `Function1` and [[scala.PartialFunction]] - * is that the latter can specify inputs which it will not handle. - */ -@annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.") -trait Function1[@specialized(Specializable.Arg) -T1, @specialized(Specializable.Return) +R] extends AnyRef { // FIXME: self => - /** Apply the body of this function to the argument. - * @return the result of function application. - */ - def apply(v1: T1): R - - /** Composes two instances of Function1 in a new Function1, with this function applied last. - * - * @tparam A the type to which function `g` can be applied - * @param g a function A => T1 - * @return a new function `f` such that `f(x) == apply(g(x))` - */ - @annotation.unspecialized def compose[A](g: A => T1): A => R = { x => apply(g(x)) } - - /** Composes two instances of Function1 in a new Function1, with this function applied first. - * - * @tparam A the result type of function `g` - * @param g a function R => A - * @return a new function `f` such that `f(x) == g(apply(x))` - */ - @annotation.unspecialized def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) } - - override def toString(): String = "" -} diff --git a/scala2-library-cc/src/scala/PartialFunction.scala b/scala2-library-cc/src/scala/PartialFunction.scala deleted file mode 100644 index 671d58be33e5..000000000000 --- a/scala2-library-cc/src/scala/PartialFunction.scala +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Scala (https://www.scala-lang.org) - * - * Copyright EPFL and Lightbend, Inc. - * - * Licensed under Apache License 2.0 - * (http://www.apache.org/licenses/LICENSE-2.0). - * - * See the NOTICE file distributed with this work for - * additional information regarding copyright ownership. - */ - -package scala - -import scala.annotation.nowarn - -/** A partial function of type `PartialFunction[A, B]` is a unary function - * where the domain does not necessarily include all values of type `A`. - * The function [[isDefinedAt]] allows to test dynamically if a value is in - * the domain of the function. - * - * Even if `isDefinedAt` returns true for an `a: A`, calling `apply(a)` may - * still throw an exception, so the following code is legal: - * - * {{{ - * val f: PartialFunction[Int, Any] = { case x => x / 0 } // ArithmeticException: / by zero - * }}} - * - * It is the responsibility of the caller to call `isDefinedAt` before - * calling `apply`, because if `isDefinedAt` is false, it is not guaranteed - * `apply` will throw an exception to indicate an error condition. If an - * exception is not thrown, evaluation may result in an arbitrary value. - * - * The usual way to respect this contract is to call [[applyOrElse]], - * which is expected to be more efficient than calling both `isDefinedAt` - * and `apply`. - * - * The main distinction between `PartialFunction` and [[scala.Function1]] is - * that the user of a `PartialFunction` may choose to do something different - * with input that is declared to be outside its domain. For example: - * - * {{{ - * val sample = 1 to 10 - * def isEven(n: Int) = n % 2 == 0 - * val eveningNews: PartialFunction[Int, String] = { - * case x if isEven(x) => s"\$x is even" - * } - * - * // The method collect is described as "filter + map" - * // because it uses a PartialFunction to select elements - * // to which the function is applied. - * val evenNumbers = sample.collect(eveningNews) - * - * val oddlyEnough: PartialFunction[Int, String] = { - * case x if !isEven(x) => s"\$x is odd" - * } - * - * // The method orElse allows chaining another PartialFunction - * // to handle input outside the declared domain. - * val numbers = sample.map(eveningNews orElse oddlyEnough) - * - * // same as - * val numbers = sample.map(n => eveningNews.applyOrElse(n, oddlyEnough)) - * - * val half: PartialFunction[Int, Int] = { - * case x if isEven(x) => x / 2 - * } - * - * // Calculating the domain of a composition can be expensive. - * val oddByHalf = half.andThen(oddlyEnough) - * - * // Invokes `half.apply` on even elements! - * val oddBalls = sample.filter(oddByHalf.isDefinedAt) - * - * // Better than filter(oddByHalf.isDefinedAt).map(oddByHalf) - * val oddBalls = sample.collect(oddByHalf) - * - * // Providing "default" values. - * val oddsAndEnds = sample.map(n => oddByHalf.applyOrElse(n, (i: Int) => s"[\$i]")) - * }}} - * - * @note Optional [[Function]]s, [[PartialFunction]]s and extractor objects - * can be converted to each other as shown in the following table. - *   - * | How to convert ... | to a [[PartialFunction]] | to an optional [[Function]] | to an extractor | - * | :---: | --- | --- | --- | - * | from a [[PartialFunction]] | [[Predef.identity]] | [[lift]] | [[Predef.identity]] | - * | from optional [[Function]] | [[Function1.UnliftOps#unlift]] or [[Function.unlift]] | [[Predef.identity]] | [[Function1.UnliftOps#unlift]] | - * | from an extractor | `{ case extractor(x) => x }` | `extractor.unapply _` | [[Predef.identity]] | - *   - * - * @define applyOrElseOrElse Note that calling [[isDefinedAt]] on the resulting partial function - * may apply the first partial function and execute its side effect. - * For efficiency, it is recommended to call [[applyOrElse]] instead of [[isDefinedAt]] or [[apply]]. - */ -trait PartialFunction[-A, +B] extends (A => B) { // FIXME: self => - import PartialFunction._ - - /** Tries to extract a `B` from an `A` in a pattern matching expression. */ - def unapply(a: A): Option[B] = lift(a) - - /** Returns an extractor object with a `unapplySeq` method, which extracts each element of a sequence data. - * - * @example {{{ - * val firstChar: String => Option[Char] = _.headOption - * - * Seq("foo", "bar", "baz") match { - * case firstChar.unlift.elementWise(c0, c1, c2) => - * println(s"\$c0, \$c1, \$c2") // Output: f, b, b - * } - * }}} - */ - def elementWise: ElementWiseExtractor[A, B] = new ElementWiseExtractor[A, B](this) - - /** Checks if a value is contained in the function's domain. - * - * @param x the value to test - * @return `'''true'''`, iff `x` is in the domain of this function, `'''false'''` otherwise. - */ - def isDefinedAt(x: A): Boolean - - /** Composes this partial function with a fallback partial function which - * gets applied where this partial function is not defined. - * - * @param that the fallback function - * @tparam A1 the argument type of the fallback function - * @tparam B1 the result type of the fallback function - * @return a partial function which has as domain the union of the domains - * of this partial function and `that`. The resulting partial function - * takes `x` to `this(x)` where `this` is defined, and to `that(x)` where it is not. - */ - def orElse[A1 <: A, B1 >: B](that: PartialFunction[A1, B1]): PartialFunction[A1, B1] = - new OrElse[A1, B1] (this, that) - //TODO: why not overload it with orElse(that: F1): F1? - - /** Composes this partial function with a transformation function that - * gets applied to results of this partial function. - * - * If the runtime type of the function is a `PartialFunction` then the - * other `andThen` method is used (note its cautions). - * - * @param k the transformation function - * @tparam C the result type of the transformation function. - * @return a partial function with the domain of this partial function, - * possibly narrowed by the specified function, which maps - * arguments `x` to `k(this(x))`. - */ - override def andThen[C](k: B => C): PartialFunction[A, C] = k match { - case pf: PartialFunction[B, C] => andThen(pf) - case _ => new AndThen[A, B, C](this, k) - } - - /** - * Composes this partial function with another partial function that - * gets applied to results of this partial function. - * - * $applyOrElseOrElse - * - * @param k the transformation function - * @tparam C the result type of the transformation function. - * @return a partial function with the domain of this partial function narrowed by - * other partial function, which maps arguments `x` to `k(this(x))`. - */ - def andThen[C](k: PartialFunction[B, C]): PartialFunction[A, C] = - new Combined[A, B, C](this, k) - - /** - * Composes another partial function `k` with this partial function so that this - * partial function gets applied to results of `k`. - * - * $applyOrElseOrElse - * - * @param k the transformation function - * @tparam R the parameter type of the transformation function. - * @return a partial function with the domain of other partial function narrowed by - * this partial function, which maps arguments `x` to `this(k(x))`. - */ - def compose[R](k: PartialFunction[R, A]): PartialFunction[R, B] = - new Combined[R, A, B](k, this) - - /** Turns this partial function into a plain function returning an `Option` result. - * @see Function.unlift - * @return a function that takes an argument `x` to `Some(this(x))` if `this` - * is defined for `x`, and to `None` otherwise. - */ - def lift: A => Option[B] = new Lifted(this) - - /** Applies this partial function to the given argument when it is contained in the function domain. - * Applies fallback function where this partial function is not defined. - * - * Note that expression `pf.applyOrElse(x, default)` is equivalent to - * {{{ if(pf isDefinedAt x) pf(x) else default(x) }}} - * except that `applyOrElse` method can be implemented more efficiently. - * For all partial function literals the compiler generates an `applyOrElse` implementation which - * avoids double evaluation of pattern matchers and guards. - * This makes `applyOrElse` the basis for the efficient implementation for many operations and scenarios, such as: - * - * - combining partial functions into `orElse`/`andThen` chains does not lead to - * excessive `apply`/`isDefinedAt` evaluation - * - `lift` and `unlift` do not evaluate source functions twice on each invocation - * - `runWith` allows efficient imperative-style combining of partial functions - * with conditionally applied actions - * - * For non-literal partial function classes with nontrivial `isDefinedAt` method - * it is recommended to override `applyOrElse` with custom implementation that avoids - * double `isDefinedAt` evaluation. This may result in better performance - * and more predictable behavior w.r.t. side effects. - * - * @param x the function argument - * @param default the fallback function - * @return the result of this function or fallback function application. - */ - def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 = - if (isDefinedAt(x)) apply(x) else default(x) - - /** Composes this partial function with an action function which - * gets applied to results of this partial function. - * The action function is invoked only for its side effects; its result is ignored. - * - * Note that expression `pf.runWith(action)(x)` is equivalent to - * {{{ if(pf isDefinedAt x) { action(pf(x)); true } else false }}} - * except that `runWith` is implemented via `applyOrElse` and thus potentially more efficient. - * Using `runWith` avoids double evaluation of pattern matchers and guards for partial function literals. - * @see `applyOrElse`. - * - * @param action the action function - * @return a function which maps arguments `x` to `isDefinedAt(x)`. The resulting function - * runs `action(this(x))` where `this` is defined. - */ - def runWith[U](action: B => U): A => Boolean = { x => - val z = applyOrElse(x, checkFallback[B]) - if (!fallbackOccurred(z)) { action(z); true } else false - } -} - -/** A few handy operations which leverage the extra bit of information - * available in partial functions. Examples: - * {{{ - * import PartialFunction._ - * - * def strangeConditional(other: Any): Boolean = cond(other) { - * case x: String if x == "abc" || x == "def" => true - * case x: Int => true - * } - * def onlyInt(v: Any): Option[Int] = condOpt(v) { case x: Int => x } - * }}} - */ -object PartialFunction { - - final class ElementWiseExtractor[-A, +B] private[PartialFunction] (private val pf: PartialFunction[A, B]) extends AnyVal { - @nowarn("cat=lint-nonlocal-return") - def unapplySeq(seq: Seq[A]): Option[Seq[B]] = { - Some(seq.map { - case pf(b) => b - case _ => return None - }) - } - } - - /** Composite function produced by `PartialFunction#orElse` method - */ - private class OrElse[-A, +B] (f1: PartialFunction[A, B], f2: PartialFunction[A, B]) - extends scala.runtime.AbstractPartialFunction[A, B] with Serializable { - def isDefinedAt(x: A) = f1.isDefinedAt(x) || f2.isDefinedAt(x) - - override def apply(x: A): B = f1.applyOrElse(x, f2) - - override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 = { - val z = f1.applyOrElse(x, checkFallback[B]) - if (!fallbackOccurred(z)) z else f2.applyOrElse(x, default) - } - - override def orElse[A1 <: A, B1 >: B](that: PartialFunction[A1, B1]): OrElse[A1, B1] = - new OrElse[A1, B1] (f1, f2 orElse that) - - override def andThen[C](k: B => C): OrElse[A, C] = - new OrElse[A, C] (f1 andThen k, f2 andThen k) - } - - /** Composite function produced by `PartialFunction#andThen` method - */ - private class AndThen[-A, B, +C] (pf: PartialFunction[A, B], k: B => C) extends PartialFunction[A, C] with Serializable { - def isDefinedAt(x: A) = pf.isDefinedAt(x) - - def apply(x: A): C = k(pf(x)) - - override def applyOrElse[A1 <: A, C1 >: C](x: A1, default: A1 => C1): C1 = { - val z = pf.applyOrElse(x, checkFallback[B]) - if (!fallbackOccurred(z)) k(z) else default(x) - } - } - - /** Composite function produced by `PartialFunction#andThen` method - */ - private class Combined[-A, B, +C] (pf: PartialFunction[A, B], k: PartialFunction[B, C]) extends PartialFunction[A, C] with Serializable { - def isDefinedAt(x: A): Boolean = { - val b: B = pf.applyOrElse(x, checkFallback[B]) - if (!fallbackOccurred(b)) k.isDefinedAt(b) else false - } - - def apply(x: A): C = k(pf(x)) - - override def applyOrElse[A1 <: A, C1 >: C](x: A1, default: A1 => C1): C1 = { - val pfv = pf.applyOrElse(x, checkFallback[B]) - if (!fallbackOccurred(pfv)) k.applyOrElse(pfv, (_: B) => default(x)) else default(x) - } - } - - /** To implement patterns like {{{ if(pf isDefinedAt x) f1(pf(x)) else f2(x) }}} efficiently - * the following trick is used: - * - * To avoid double evaluation of pattern matchers & guards `applyOrElse` method is used here - * instead of `isDefinedAt`/`apply` pair. - * - * After call to `applyOrElse` we need both the function result it returned and - * the fact if the function's argument was contained in its domain. The only degree of freedom we have here - * to achieve this goal is tweaking with the continuation argument (`default`) of `applyOrElse` method. - * The obvious way is to throw an exception from `default` function and to catch it after - * calling `applyOrElse` but I consider this somewhat inefficient. - * - * I know only one way how you can do this task efficiently: `default` function should return unique marker object - * which never may be returned by any other (regular/partial) function. This way after calling `applyOrElse` you need - * just one reference comparison to distinguish if `pf isDefined x` or not. - * - * This correctly interacts with specialization as return type of `applyOrElse` - * (which is parameterized upper bound) can never be specialized. - * - * Here `fallback_fn` is used as both unique marker object and special fallback function that returns it. - */ - private[this] val fallback_fn: Any => Any = _ => fallback_fn - private def checkFallback[B] = fallback_fn.asInstanceOf[Any => B] - private def fallbackOccurred[B](x: B) = fallback_fn eq x.asInstanceOf[AnyRef] - - private class Lifted[-A, +B] (val pf: PartialFunction[A, B]) - extends scala.runtime.AbstractFunction1[A, Option[B]] with Serializable { - - def apply(x: A): Option[B] = { - val z = pf.applyOrElse(x, checkFallback[B]) - if (!fallbackOccurred(z)) Some(z) else None - } - } - - private class Unlifted[A, B] (f: A => Option[B]) extends scala.runtime.AbstractPartialFunction[A, B] with Serializable { - def isDefinedAt(x: A): Boolean = f(x).isDefined - - override def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 = { - f(x).getOrElse(default(x)) - } - - override def lift = f - } - - private[scala] def unlifted[A, B](f: A => Option[B]): PartialFunction[A, B] = f match { - case lf: Lifted[A, B] => lf.pf - case ff => new Unlifted(ff) - } - - /** Converts an ordinary function to a partial function. Note that calling `isDefinedAt(x)` on - * this partial function will return `true` for every `x`. - * @param f an ordinary function - * @return a partial function which delegates to the ordinary function `f` - */ - def fromFunction[A, B](f: A => B): PartialFunction[A, B] = { case x => f(x) } - - private[this] val constFalse: Any => Boolean = { _ => false} - - private[this] val empty_pf: PartialFunction[Any, Nothing] = new PartialFunction[Any, Nothing] with Serializable { - def isDefinedAt(x: Any) = false - def apply(x: Any) = throw new MatchError(x) - override def orElse[A1, B1](that: PartialFunction[A1, B1]) = that - override def andThen[C](k: Nothing => C): PartialFunction[Any, Nothing] = this - override val lift: Any => None.type = (x: Any) => None - override def runWith[U](action: Nothing => U) = constFalse - } - - /** The partial function with empty domain. - * Any attempt to invoke empty partial function leads to throwing [[scala.MatchError]] exception. - */ - def empty[A, B] : PartialFunction[A, B] = empty_pf - - /** A Boolean test that is the result of the given function where defined, - * and false otherwise. - * - * It behaves like a `case _ => false` were added to the partial function. - * - * @param x the value to test - * @param pf the partial function - * @return true, iff `x` is in the domain of `pf` and `pf(x) == true`. - */ - def cond[A](x: A)(pf: PartialFunction[A, Boolean]): Boolean = pf.applyOrElse(x, constFalse) - - /** Apply the function to the given value if defined, and return the result - * in a `Some`; otherwise, return `None`. - * - * @param x the value to test - * @param pf the PartialFunction[T, U] - * @return `Some(pf(x))` if `pf isDefinedAt x`, `None` otherwise. - */ - def condOpt[A, B](x: A)(pf: PartialFunction[A, B]): Option[B] = { - val z = pf.applyOrElse(x, checkFallback[B]) - if (!fallbackOccurred(z)) Some(z) else None - } -} diff --git a/scala2-library-cc/src/scala/TODO b/scala2-library-cc/src/scala/TODO deleted file mode 100644 index 241779ab8dd9..000000000000 --- a/scala2-library-cc/src/scala/TODO +++ /dev/null @@ -1 +0,0 @@ -- Delete or re-clone Function1 and PartialFunction. These where edited to remove the self type. From ba54ff3fdbe8d18d856b3d92ebdae6591c646ce7 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 3 Jan 2024 11:41:14 +0100 Subject: [PATCH 3/5] Revert "Add capture checking to `scala/language.scala`" This reverts commit af897ca7a06527ad8e3d2e8a8b7db7005d4e2f5b. --- scala2-library-cc/src/scala/language.scala | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scala2-library-cc/src/scala/language.scala b/scala2-library-cc/src/scala/language.scala index 757b9dac1076..63c6f1f76fa6 100644 --- a/scala2-library-cc/src/scala/language.scala +++ b/scala2-library-cc/src/scala/language.scala @@ -188,12 +188,6 @@ object language { import languageFeature.experimental._ - /** Experimental support for capture checking; implies support for pureFunctions - * - * @see [[https://dotty.epfl.ch/docs/reference/experimental/cc]] - */ - implicit lazy val captureChecking: existentials = languageFeature.existentials - /** Only where this feature is enabled, are macro definitions allowed. * If `macros` is not enabled, macro definitions are rejected by the compiler. * From 444231d8735dbf3d914431f934a564f7f2c50393 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 3 Jan 2024 11:41:27 +0100 Subject: [PATCH 4/5] Revert "Clone `scala/language.scala`" This reverts commit e1efffdea9c55fe8741e8e5324ce8a1615f4d04e. --- scala2-library-cc/src/scala/language.scala | 207 --------------------- 1 file changed, 207 deletions(-) delete mode 100644 scala2-library-cc/src/scala/language.scala diff --git a/scala2-library-cc/src/scala/language.scala b/scala2-library-cc/src/scala/language.scala deleted file mode 100644 index 63c6f1f76fa6..000000000000 --- a/scala2-library-cc/src/scala/language.scala +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Scala (https://www.scala-lang.org) - * - * Copyright EPFL and Lightbend, Inc. - * - * Licensed under Apache License 2.0 - * (http://www.apache.org/licenses/LICENSE-2.0). - * - * See the NOTICE file distributed with this work for - * additional information regarding copyright ownership. - */ - -package scala - -/** - * The `scala.language` object controls the language features available to the programmer, as proposed in the - * [[https://docs.google.com/document/d/1nlkvpoIRkx7at1qJEZafJwthZ3GeIklTFhqmXMvTX9Q/edit '''SIP-18 document''']]. - * - * Each of these features has to be explicitly imported into the current scope to become available: - * {{{ - * import language.postfixOps // or language._ - * List(1, 2, 3) reverse - * }}} - * - * The language features are: - * - [[dynamics `dynamics`]] enables defining calls rewriting using the [[scala.Dynamic `Dynamic`]] trait - * - [[existentials `existentials`]] enables writing existential types - * - [[higherKinds `higherKinds`]] enables writing higher-kinded types - * - [[implicitConversions `implicitConversions`]] enables defining implicit methods and members - * - [[postfixOps `postfixOps`]] enables postfix operators (not recommended) - * - [[reflectiveCalls `reflectiveCalls`]] enables using structural types - * - [[experimental `experimental`]] contains newer features that have not yet been tested in production - * - * @groupname production Language Features - * @groupname experimental Experimental Language Features - * @groupprio experimental 10 - */ -object language { - - import languageFeature._ - - /** Only where this feature is enabled, can direct or indirect subclasses of trait scala.Dynamic - * be defined. If `dynamics` is not enabled, a definition of a class, trait, - * or object that has `Dynamic` as a base trait is rejected by the compiler. - * - * Selections of dynamic members of existing subclasses of trait `Dynamic` are unaffected; - * they can be used anywhere. - * - * '''Why introduce the feature?''' To enable flexible DSLs and convenient interfacing - * with dynamic languages. - * - * '''Why control it?''' Dynamic member selection can undermine static checkability - * of programs. Furthermore, dynamic member selection often relies on reflection, - * which is not available on all platforms. - * - * @group production - */ - implicit lazy val dynamics: dynamics = languageFeature.dynamics - - /** Only where this feature is enabled, is postfix operator notation `(expr op)` permitted. - * If `postfixOps` is not enabled, an expression using postfix notation is rejected by the compiler. - * - * '''Why keep the feature?''' Postfix notation is preserved for backward - * compatibility only. Historically, several DSLs written in Scala need the notation. - * - * '''Why control it?''' Postfix operators interact poorly with semicolon inference. - * Most programmers avoid them for this reason alone. Postfix syntax is - * associated with an abuse of infix notation, `a op1 b op2 c op3`, - * that can be harder to read than ordinary method invocation with judicious - * use of parentheses. It is recommended not to enable this feature except for - * legacy code. - * - * @group production - */ - implicit lazy val postfixOps: postfixOps = languageFeature.postfixOps - - /** Where this feature is enabled, accesses to members of structural types that need - * reflection are supported. If `reflectiveCalls` is not enabled, an expression - * requiring reflection will trigger a warning from the compiler. - * - * A structural type is a type of the form - * `Parents { Decls }` where `Decls` contains declarations of new members that do - * not override any member in `Parents`. To access one of these members, a - * reflective call is needed. - * - * '''Why keep the feature?''' Structural types provide great flexibility because - * they avoid the need to define inheritance hierarchies a priori. Besides, - * their definition falls out quite naturally from Scala’s concept of type refinement. - * - * '''Why control it?''' Reflection is not available on all platforms. Popular tools - * such as ProGuard have problems dealing with it. Even where reflection is available, - * reflective dispatch can lead to surprising performance degradations. - * - * @group production - */ - implicit lazy val reflectiveCalls: reflectiveCalls = languageFeature.reflectiveCalls - - /** Where this feature is enabled, definitions of implicit conversions are allowed. - * If `implicitConversions` is not enabled, the definition of an implicit - * conversion will trigger a warning from the compiler. - * - * An implicit conversion is an implicit value of unary function type `A => B`, - * or an implicit method that has in its first parameter section a single, - * non-implicit parameter. Examples: - * - * {{{ - * implicit def stringToInt(s: String): Int = s.length - * implicit val conv = (s: String) => s.length - * implicit def listToX(xs: List[T])(implicit f: T => X): X = ... - * }}} - * - * Implicit classes and implicit values of other types are not governed by this - * language feature. - * - * '''Why keep the feature?''' Implicit conversions are central to many aspects - * of Scala’s core libraries. - * - * '''Why control it?''' Implicit conversions are known to cause many pitfalls - * if over-used. And there is a tendency to over-use them because they look - * very powerful and their effects seem to be easy to understand. Also, in - * most situations using implicit parameters leads to a better design than - * implicit conversions. - * - * @group production - */ - implicit lazy val implicitConversions: implicitConversions = languageFeature.implicitConversions - - /** Where this feature is enabled, higher-kinded types can be written. - * If `higherKinds` is not enabled, a higher-kinded type such as `F[A]` - * will trigger a warning from the compiler. - * - * '''Why keep the feature?''' Higher-kinded types enable the definition of very general - * abstractions such as functor, monad, or arrow. A significant set of advanced - * libraries relies on them. Higher-kinded types are also at the core of the - * scala-virtualized effort to produce high-performance parallel DSLs through staging. - * - * '''Why control it?''' Higher kinded types in Scala lead to a Turing-complete - * type system, where compiler termination is no longer guaranteed. They tend - * to be useful mostly for type-level computation and for highly generic design - * patterns. The level of abstraction implied by these design patterns is often - * a barrier to understanding for newcomers to a Scala codebase. Some syntactic - * aspects of higher-kinded types are hard to understand for the uninitiated and - * type inference is less effective for them than for normal types. Because we are - * not completely happy with them yet, it is possible that some aspects of - * higher-kinded types will change in future versions of Scala. So an explicit - * enabling also serves as a warning that code involving higher-kinded types - * might have to be slightly revised in the future. - * - * @group production - */ - @deprecated("higherKinds no longer needs to be imported explicitly", "2.13.1") - implicit lazy val higherKinds: higherKinds = languageFeature.higherKinds - - /** Where this feature is enabled, existential types that cannot be expressed as wildcard - * types can be written and are allowed in inferred types of values or return - * types of methods. If `existentials` is not enabled, those cases will trigger - * a warning from the compiler. - * - * Existential types with wildcard type syntax such as `List[_]`, - * or `Map[String, _]` are not affected. - * - * '''Why keep the feature?''' Existential types are needed to make sense of Java’s wildcard - * types and raw types and the erased types of run-time values. - * - * '''Why control it?''' Having complex existential types in a code base usually makes - * application code very brittle, with a tendency to produce type errors with - * obscure error messages. Therefore, going overboard with existential types - * is generally perceived not to be a good idea. Also, complicated existential types - * might be no longer supported in a future simplification of the language. - * - * @group production - */ - implicit lazy val existentials: existentials = languageFeature.existentials - - /** The experimental object contains features that are known to have unstable API or - * behavior that may change in future releases. - * - * Experimental features '''may undergo API changes''' in future releases, so production - * code should not rely on them. - * - * Programmers are encouraged to try out experimental features and - * [[https://github.com/scala/bug/issues report any bugs or API inconsistencies]] - * they encounter so they can be improved in future releases. - * - * @group experimental - */ - object experimental { - - import languageFeature.experimental._ - - /** Only where this feature is enabled, are macro definitions allowed. - * If `macros` is not enabled, macro definitions are rejected by the compiler. - * - * Macro implementations and macro applications are not governed by this - * language feature; they can be used anywhere. - * - * '''Why introduce the feature?''' Macros promise to make the language more regular, - * replacing ad-hoc language constructs with a general powerful abstraction - * capability that can express them. Macros are also a more disciplined and - * powerful replacement for compiler plugins. - * - * '''Why control it?''' For their very power, macros can lead to code that is hard - * to debug and understand. - */ - implicit lazy val macros: macros = languageFeature.experimental.macros - } -} From 8a0d8032b5c605eb69874ba1c26ed4d8f0d24ae2 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 3 Jan 2024 11:41:39 +0100 Subject: [PATCH 5/5] Revert "Add `scala2-library-cc-tasty` project" This reverts commit a8d807bfad84785bbe4dc92836a1aa848665d6c1. --- .github/workflows/ci.yaml | 11 +---- build.sbt | 2 - project/Build.scala | 98 +++++++++------------------------------ 3 files changed, 23 insertions(+), 88 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9075abcdf36e..fd1fe30d3fa9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -145,10 +145,7 @@ jobs: ./project/scripts/sbt ";sjsSandbox/run ;sjsSandbox/test ;sjsJUnitTests/test ;set sjsJUnitTests/scalaJSLinkerConfig ~= switchToESModules ;sjsJUnitTests/test ;sjsCompilerTests/test" - name: Test with Scala 2 library TASTy (fast) - run: ./project/scripts/sbt ";set ThisBuild/Build.scala2Library := Build.Scala2LibraryTasty ;scala3-bootstrapped/testCompilation i5; scala3-bootstrapped/testCompilation tests/run/typelevel-peano.scala; scala3-bootstrapped/testOnly dotty.tools.backend.jvm.DottyBytecodeTests" # only test a subset of test to avoid doubling the CI execution time - - - name: Test with Scala 2 library with CC TASTy (fast) - run: ./project/scripts/sbt ";set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty ;scala2-library-tasty/compile" # TODO test all the test configurations in non-CC library (currently disabled due to bug while loading the library) + run: ./project/scripts/sbt ";set ThisBuild/Build.useScala2LibraryTasty := true ;scala3-bootstrapped/testCompilation i5; scala3-bootstrapped/testCompilation tests/run/typelevel-peano.scala; scala3-bootstrapped/testOnly dotty.tools.backend.jvm.DottyBytecodeTests" # only test a subset of test to avoid doubling the CI execution time test_scala2_library_tasty: runs-on: [self-hosted, Linux] @@ -189,11 +186,7 @@ jobs: run: cp -vf .github/workflows/repositories /root/.sbt/ ; true - name: Test with Scala 2 library TASTy - run: ./project/scripts/sbt ";set ThisBuild/Build.scala2Library := Build.Scala2LibraryTasty ;scala3-bootstrapped/test" - - # TODO test all the test configurations in non-CC library (currently disabled due to bug while loading the library) - # - name: Test with Scala 2 library with CC TASTy - # run: ./project/scripts/sbt ";set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty ;scala3-bootstrapped/test" + run: ./project/scripts/sbt ";set ThisBuild/Build.useScala2LibraryTasty := true ;scala3-bootstrapped/test" test_windows_fast: diff --git a/build.sbt b/build.sbt index 1712e80405ae..9b6ebc194ea0 100644 --- a/build.sbt +++ b/build.sbt @@ -17,8 +17,6 @@ val `scala3-bench-micro` = Build.`scala3-bench-micro` val `scala2-library-bootstrapped` = Build.`scala2-library-bootstrapped` val `scala2-library-tasty` = Build.`scala2-library-tasty` val `scala2-library-tasty-tests` = Build.`scala2-library-tasty-tests` -val `scala2-library-cc` = Build.`scala2-library-cc` -val `scala2-library-cc-tasty` = Build.`scala2-library-cc-tasty` val `tasty-core` = Build.`tasty-core` val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped` val `tasty-core-scala2` = Build.`tasty-core-scala2` diff --git a/project/Build.scala b/project/Build.scala index 2dcbfb0b29f9..b799c32eb65a 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -173,23 +173,11 @@ object Build { // Run tests with filter through vulpix test suite val testCompilation = inputKey[Unit]("runs integration test with the supplied filter") - sealed trait Scala2Library - // Use Scala 2 compiled library JAR - object Scala2LibraryJar extends Scala2Library // Use the TASTy jar from `scala2-library-tasty` in the classpath // This only works with `scala3-bootstrapped/scalac` and tests in `scala3-bootstrapped` // - object Scala2LibraryTasty extends Scala2Library - // Use the TASTy jar from `scala2-library-cc-tasty` in the classpath - // This only works with `scala3-bootstrapped/scalac` and tests in `scala3-bootstrapped` - // - object Scala2LibraryCCTasty extends Scala2Library - - // Set in SBT with: - // - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryJar` (default) - // - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryTasty` - // - `set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty` - val scala2Library = settingKey[Scala2Library]("Choose which version of the Scala 2 library should be used") + // Enable in SBT with: `set ThisBuild/Build.useScala2LibraryTasty := true` + val useScala2LibraryTasty = settingKey[Boolean]("Use the TASTy jar from `scala2-library-tasty` in the classpath") // Used to compile files similar to ./bin/scalac script val scalac = inputKey[Unit]("run the compiler using the correct classpath, or the user supplied classpath") @@ -237,7 +225,7 @@ object Build { outputStrategy := Some(StdoutOutput), - scala2Library := Scala2LibraryJar, + useScala2LibraryTasty := false, // enable verbose exception messages for JUnit (Test / testOptions) += Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "-s"), @@ -657,18 +645,12 @@ object Build { val externalDeps = externalCompilerClasspathTask.value val jars = packageAll.value - def libraryPathProperty(jarName: String): Seq[String] = - jars.get(jarName) match { - case Some(jar) => - Seq(s"-Ddotty.tests.tasties.scalaLibrary=$jar") - case None => - log.warn("Scala 2 library TASTy is ignored on non-bootstrapped compiler") - Seq.empty - } - val scala2LibraryTasty = scala2Library.value match { - case Scala2LibraryJar => Seq.empty - case Scala2LibraryTasty => libraryPathProperty("scala2-library-tasty") - case Scala2LibraryCCTasty => libraryPathProperty("scala2-library-cc-tasty") + val scala2LibraryTasty = jars.get("scala2-library-tasty") match { + case Some(scala2LibraryTastyJar) if useScala2LibraryTasty.value => + Seq("-Ddotty.tests.tasties.scalaLibrary=" + scala2LibraryTastyJar) + case _ => + if (useScala2LibraryTasty.value) log.warn("useScala2LibraryTasty is ignored on non-bootstrapped compiler") + Seq.empty } scala2LibraryTasty ++ Seq( @@ -782,24 +764,14 @@ object Build { else if (debugFromTasty) "dotty.tools.dotc.fromtasty.Debug" else "dotty.tools.dotc.Main" - val scala2LibraryTasty = scala2Library.value match { - case Scala2LibraryJar => Seq.empty - case Scala2LibraryTasty => - jars.get("scala2-library-tasty") match { - case Some(jar) => Seq(jar) - case None => - log.warn("Scala2LibraryTasty is ignored on non-bootstrapped compiler") - Seq.empty - } - case Scala2LibraryCCTasty => - jars.get("scala2-library-cc-tasty") match { - case Some(jar) => Seq(jar) - case None => - log.warn("Scala2LibraryCCTasty is ignored on non-bootstrapped compiler") - Seq.empty - } - } - var extraClasspath = scala2LibraryTasty ++ Seq(scalaLib, dottyLib) + var extraClasspath = + scalaLibTastyOpt match { + case Some(scalaLibTasty) if useScala2LibraryTasty.value => + Seq(scalaLibTasty, scalaLib, dottyLib) + case _ => + if (useScala2LibraryTasty.value) log.warn("useScala2LibraryTasty is ignored on non-bootstrapped compiler") + Seq(scalaLib, dottyLib) + } if (decompile && !args.contains("-classpath")) extraClasspath ++= Seq(".") @@ -910,7 +882,6 @@ object Build { "scala3-tasty-inspector" -> (LocalProject("scala3-tasty-inspector") / Compile / packageBin).value.getAbsolutePath, "tasty-core" -> (LocalProject("tasty-core-bootstrapped") / Compile / packageBin).value.getAbsolutePath, "scala2-library-tasty" -> (LocalProject("scala2-library-tasty") / Compile / packageBin).value.getAbsolutePath, - "scala2-library-cc-tasty" -> (LocalProject("scala2-library-cc-tasty") / Compile / packageBin).value.getAbsolutePath, ) }, @@ -1039,24 +1010,8 @@ object Build { withCommonSettings(Bootstrapped). dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test"). settings(commonBootstrappedSettings). - settings(scala2LibraryBootstrappedSettings). - settings(moduleName := "scala2-library") - - /** Scala 2 library compiled by dotty using the latest published sources of the library. - * - * This version of the library is not (yet) TASTy/binary compatible with the Scala 2 compiled library. - */ - lazy val `scala2-library-cc` = project.in(file("scala2-library-cc")). - withCommonSettings(Bootstrapped). - dependsOn(dottyCompiler(Bootstrapped) % "provided; compile->runtime; test->test"). - settings(commonBootstrappedSettings). - settings(scala2LibraryBootstrappedSettings). settings( - moduleName := "scala2-library-cc", - scalacOptions += "-Ycheck:all", - ) - - lazy val scala2LibraryBootstrappedSettings = Seq( + moduleName := "scala2-library", javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value, Compile / scalacOptions ++= { Seq("-sourcepath", ((Compile/sourceManaged).value / "scala-library-src").toString) @@ -1141,13 +1096,13 @@ object Build { | - final val MinorVersion = $minorVersion | - final val ExperimentalVersion = 0 | * Clean everything to generate a compiler with those new TASTy versions - | * Run ${name.value}/tastyMiMaReportIssues + | * Run scala2-library-bootstrapped/tastyMiMaReportIssues |""".stripMargin) }).value, Compile / exportJars := true, artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) => - moduleName.value + "-" + dottyVersion + "." + artifact.extension + "scala2-library-" + dottyVersion + "." + artifact.extension }, run := { val log = streams.value.log @@ -1219,7 +1174,7 @@ object Build { |""".stripMargin) } } - ) + ) /** Packages the TASTy files of `scala2-library-bootstrapped` in a jar */ lazy val `scala2-library-tasty` = project.in(file("scala2-library-tasty")). @@ -1232,17 +1187,6 @@ object Build { }, ) - /** Packages the TASTy files of `scala2-library-cc` in a jar */ - lazy val `scala2-library-cc-tasty` = project.in(file("scala2-library-cc-tasty")). - withCommonSettings(Bootstrapped). - settings( - exportJars := true, - Compile / packageBin / mappings := { - (`scala2-library-cc` / Compile / packageBin / mappings).value - .filter(_._2.endsWith(".tasty")) - }, - ) - /** Test the tasty generated by `scala2-library-bootstrapped` * * The sources in src are compiled using TASTy from scala2-library-tasty but then run