8000 Merge pull request #5075 from sjrd/ju-sequencedcollection-types-only · scala-js/scala-js@da2554d · GitHub
[go: up one dir, main page]

Skip to content

Commit da2554d

Browse files
authored
Merge pull request #5075 from sjrd/ju-sequencedcollection-types-only
Add trait definitions for ju.Sequenced{Collection,Map,Set}.
2 parents 69e4880 + 8f98b8f commit da2554d

File tree

13 files changed

+194
-6
lines changed

13 files changed

+194
-6
lines changed

javalib/src/main/scala/java/util/Deque.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
package java.util
1414

15-
trait Deque[E] extends Queue[E] {
15+
trait Deque[E] extends Queue[E] with SequencedCollection[E] {
1616
def addFirst(e: E): Unit
1717
def addLast(e: E): Unit
1818
def offerFirst(e: E): Boolean

javalib/src/main/scala/java/util/LinkedHashMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import java.util.function.BiConsumer
1717

1818
class LinkedHashMap[K, V](initialCapacity: Int, loadFactor: Float,
1919
accessOrder: Boolean)
20-
extends HashMap[K, V](initialCapacity, loadFactor) {
20+
extends HashMap[K, V](initialCapacity, loadFactor) with SequencedMap[K, V] {
2121
self =>
2222

2323
import LinkedHashMap._

javalib/src/main/scala/java/util/LinkedHashSet.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ package java.util
1515
import java.lang.Cloneable
1616

1717
class LinkedHashSet[E] private[util] (inner: LinkedHashMap[E, Any])
18-
extends HashSet[E](inner) with Set[E] with Cloneable with Serializable {
18+
extends HashSet[E](inner) with SequencedSet[E] with Cloneable with Serializable {
1919

2020
def this(initialCapacity: Int, loadFactor: Float) =
2121
this(new LinkedHashMap[E, Any](initialCapacity, loadFactor))

javalib/src/main/scala/java/util/List.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ package java.util
1414

1515
import java.util.function.UnaryOperator
1616

17-
trait List[E] extends Collection[E] {
17+
trait List[E] extends SequencedCollection[E] {
1818
def replaceAll(operator: UnaryOperator[E]): Unit = {
1919
val iter = listIterator()
2020
while (iter.hasNext())
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util
14+
15+
trait SequencedCollection[E] extends Collection[E]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util
14+
15+
import java.util.Map.Entry
16+
17+
trait SequencedMap[K, V] extends Map[K, V]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util
14+
15+
trait SequencedSet[E] extends SequencedCollection[E] with Set[E]

javalib/src/main/scala/java/util/SortedMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
package java.util
1414

15-
trait SortedMap[K, V] extends Map[K, V] {
15+
trait SortedMap[K, V] extends SequencedMap[K, V] {
1616
def firstKey(): K
1717
def comparator(): Comparator[_ >: K]
1818
def lastKey(): K

javalib/src/main/scala/java/util/SortedSet.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
package java.util
1414

15-
trait SortedSet[E] extends Set[E] {
15+
trait SortedSet[E] extends SequencedSet[E] {
1616
def comparator(): Comparator[_ >: E]
1717
def subSet(fromElement: E, toElement: E): SortedSet[E]
1818
def headSet(toElement: E): SortedSet[E]

project/Build.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,7 @@ object Build {
21342134
collectionsEraDependentDirectory(scalaV, sharedTestDir) ::
21352135
includeIf(sharedTestDir / "require-jdk11", javaV >= 11) :::
21362136
includeIf(sharedTestDir / "require-jdk15", javaV >= 15) :::
2137+
includeIf(sharedTestDir / "require-jdk21", javaV >= 21) :::
21372138
includeIf(testDir / "require-scala2", isJSTest)
21382139
},
21392140

0 commit comments

Comments
 (0)
0