Skip to content

Commit 46327f5

Browse files
committed
Add {mutable,immutable}.Iterable.scala to stdlib tests
1 parent af8124f commit 46327f5

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Scala (https://www.scala-lang.org)
3+
*
4+
* Copyright EPFL and Lightbend, Inc.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (http://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 scala.collection.immutable
14+
15+
import scala.collection.{IterableFactory, IterableFactoryDefaults}
16+
import language.experimental.captureChecking
17+
18+
/** A trait for collections that are guaranteed immutable.
19+
*
20+
* @tparam A the element type of the collection
21+
*
22+
* @define coll immutable collection
23+
* @define Coll `immutable.Iterable`
24+
*/
25+
trait Iterable[+A] extends collection.Iterable[A]
26+
with collection.IterableOps[A, Iterable, Iterable[A]]
27+
with IterableFactoryDefaults[A, Iterable] {
28+
this: Iterable[A]^ =>
29+
30+
override def iterableFactory: IterableFactory[Iterable] = Iterable
31+
}
32+
33+
@SerialVersionUID(3L)
34+
object Iterable extends IterableFactory.Delegate[Iterable](List) {
35+
override def from[E](it: IterableOnce[E]): Iterable[E] = it match {
36+
case iterable: Iterable[E] => iterable
37+
case _ => super.from(it)
38+
}
39+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Scala (https://www.scala-lang.org)
3+
*
4+
* Copyright EPFL and Lightbend, Inc.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (http://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 scala.collection.mutable
14+
15+
import scala.collection.{IterableFactory, IterableFactoryDefaults}
16+
import language.experimental.captureChecking
17+
18+
trait Iterable[A]
19+
extends collection.Iterable[A]
20+
with collection.IterableOps[A, Iterable, Iterable[A]]
21+
with IterableFactoryDefaults[A, Iterable] {
22+
this: Iterable[A]^ =>
23+
24+
override def iterableFactory: IterableFactory[Iterable] = Iterable
25+
}
26+
27+
/**
28+
* $factoryInfo
29+
* @define coll mutable collection
30+
* @define Coll `mutable.Iterable`
31+
*/
32+
@SerialVersionUID(3L)
33+
object Iterable extends IterableFactory.Delegate[Iterable](ArrayBuffer)
34+
35+
/** Explicit instantiation of the `Iterable` trait to reduce class file size in subclasses. */
36+
abstract class AbstractIterable[A] extends scala.collection.AbstractIterable[A] with Iterable[A]:
37+
this: AbstractIterable[A]^ =>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
collection/immutable/Iterable.scala
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
collection/mutable/Iterable.scala

0 commit comments

Comments
 (0)