Skip to content

Commit 25035d7

Browse files
committed
Tweak generics.IsSeq
1 parent e304d8a commit 25035d7

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

scala2-library-cc/src/scala/collection/generic/IsSeq.scala

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,20 @@ object IsSeq {
5454
seqOpsIsSeqVal.asInstanceOf[IsSeq[CC0[A0]] { type A = A0; type C = CC0[A0] }]
5555

5656
/** !!! Under cc, views are not Seqs and can't use SeqOps.
57-
* So this should be renamed to seqViewIsIterable
58-
*/
59-
implicit def seqViewIsSeq[CC0[X] <: SeqView[X], A0]: IsIterable[CC0[A0]] { type A = A0; type C = View[A0] } =
60-
new IsIterable[CC0[A0]] {
61-
type A = A0
62-
type C = View[A]
63-
def apply(coll: CC0[A0]): IterableOps[A0, View, View[A0]] = coll
64-
}
57+
* Therefore, [[seqViewIsSeq]] now returns an [[IsIterable]].
58+
* The helper method [[seqViewIsSeq_]] is added to make the binary compatible.
59+
*/
60+
@annotation.targetName("seqViewIsSeq")
61+
def seqViewIsSeq_[CC0[X] <: SeqView[X], A0]: IsSeq[CC0[A0]] { type A = A0; type C = View[A0] } = ???
62+
implicit inline def seqViewIsSeq[CC0[X] <: SeqView[X], A0]: IsIterable[CC0[A0]] { type A = A0; type C = View[A0] } = seqViewIsSeq_[CC0, A0].asInstanceOf
6563

6664
/** !!! Under cc, views are not Seqs and can't use SeqOps.
67-
* So this should be renamed to stringViewIsIterable
68-
*/
69-
implicit val stringViewIsSeq: IsIterable[StringView] { type A = Char; type C = View[Char] } =
70-
new IsIterable[StringView] {
71-
type A = Char
72-
type C = View[Char]
73-
def apply(coll: StringView): IterableOps[Char, View, View[Char]] = coll
74-
}
65+
* Therefore, [[stringViewIsSeq]] now returns an [[IsIterable]].
66+
* The helper method [[stringViewIsSeq__]] is added to make the binary compatible.
67+
*/
68+
@annotation.targetName("stringViewIsSeq")
69+
val stringViewIsSeq_ : IsSeq[StringView] { type A = Char; type C = View[Char] } = ???
70+
inline implicit def stringViewIsSeq: IsIterable[StringView] { type A = Char; type C = View[Char] } = stringViewIsSeq_.asInstanceOf
7571

7672
implicit val stringIsSeq: IsSeq[String] { type A = Char; type C = String } =
7773
new IsSeq[String] {

tests/run/enrich-gentraversable.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import scala.language.postfixOps
33

44
object Test extends App {
55
import scala.collection.generic.IsIterable
6+
import scala.collection.generic.IsSeq.seqViewIsSeq
67
import scala.collection.{BuildFrom, Iterable, IterableOps, View}
78
import scala.collection.immutable.TreeMap
89

0 commit comments

Comments
 (0)