Skip to content

Rewrite scala.collection.LinearSeq => scala.collection.immutable.List is incorrect #99

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

Closed
MasseGuillaume opened this issue Jul 17, 2018 · 3 comments

Comments

@MasseGuillaume
Copy link
Contributor

The Subclass of LinearSeq are: List, Stream, Queue, Stack.

It would break with the following call at use site:

class A(v: LinearSeq[Int])

new A(Stream(1))

becomes

class A(v: List[Int])

new A(Stream(1))
// found Steam[Int]
// requires List[Int]
@julienrf
Copy link
Contributor

We should indeed rewrite only LinearSeq.apply(...) to List.apply(...). Occurrences of LinearSeq in type position should not be changed. If we want to not change how types are inferred, we could rewrite to List.apply(...): LinearSeq[X] instead.

@MasseGuillaume
Copy link
Contributor Author

It Looks like LinearSeq was not removed after all: https://github.com/scala/scala/blob/2.13.x/src/library/scala/collection/LinearSeq.scala

Can we just remove the rewrite rule?

@julienrf
Copy link
Contributor

Yes.

julienrf added a commit that referenced this issue Aug 1, 2018
Remove LinearSeq -> List rewrite (fix #99)
martijnhoekstra pushed a commit to martijnhoekstra/scala-collection-compat that referenced this issue Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants