scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.88k stars 1.06k forks source link

view.updated not a member of IndexedSeqView in CC library #19660

Closed nicolasstucki closed 8 months ago

nicolasstucki commented 9 months ago

Minimization of tests/run/t5328.scala

// Test.scala
def test = Vector(1).view.updated(0,2)
sbt> set ThisBuild/Build.scala2Library := Build.Scala2LibraryCCTasty
sbt> scala3-bootstrapped/scalac Test.scala
1 |def test = Vector(1).view.updated(0,2)
  |           ^^^^^^^^^^^^^^^^^^^^^^
  |     value updated is not a member of scala.collection.IndexedSeqView[Int]

Originally posted by @nicolasstucki in https://github.com/lampepfl/dotty/issues/19652#issuecomment-1935559226

Linyxus commented 9 months ago

So I checked the issue and discovered that this is actually not a bug in the capture checker and an outcome of a change made in the capture checked stdlib. In the original stdlib, the updated function of IndexedSeqView comes from the SeqOps trait. But now IndexedSeqView extends IndexedSeqViewOps, which in the end extends IterableOps instead of SeqOps, as explained in the comment here.

I'm not quite confident about how it should be fixed. Should we add a method in SeqViewOps? /cc @odersky

odersky commented 9 months ago

That's a tricky one. Maybe we can add updated to SeqViewOps as an inline method? That should be backwards Tasty compatible.