Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more methods in SeqViewOps #19993

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scala2-library-cc/src/scala/collection/Seq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
* Note that :-ending operators are right associative (see example).
* A mnemonic for `+:` vs. `:+` is: the COLon goes on the COLlection side.
*/
@`inline` final def +: [B >: A](elem: B): CC[B] = prepended(elem)
@`inline` override final def +: [B >: A](elem: B): CC[B] = prepended(elem)

/** A copy of this $coll with an element appended.
*
Expand Down Expand Up @@ -148,7 +148,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
* Note that :-ending operators are right associative (see example).
* A mnemonic for `+:` vs. `:+` is: the COLon goes on the COLlection side.
*/
@`inline` final def :+ [B >: A](elem: B): CC[B] = appended(elem)
@`inline` override final def :+ [B >: A](elem: B): CC[B] = appended(elem)

/** As with `:++`, returns a new collection containing the elements from the left operand followed by the
* elements from the right operand.
Expand Down
4 changes: 4 additions & 0 deletions scala2-library-cc/src/scala/collection/SeqView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ trait SeqViewOps[+A, +CC[_], +C] extends Any with IterableOps[A, CC, C] {
def distinctBy[B](f: A -> B): C^{this} =
assert(false, "This is a placeholder implementation in the capture checked Scala 2 library.")
???

// The following methods are copied from [[SeqOps]].
@`inline` def +: [B >: A](elem: B): CC[B]^{this} = prepended(elem)
@`inline` def :+ [B >: A](elem: B): CC[B]^{this} = appended(elem)
// -------------------

def reverseIterator: Iterator[A]^{this} = reversed.iterator
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i19988.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import collection.IndexedSeqView
object Hello extends App {
def foo(view: IndexedSeqView[Int]): Unit =
val x1 = 1 +: view
val x2 = view :+ 1
}