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

Drop FreeSeqFactory from stdlib-cc #19849

Merged
merged 2 commits into from
Mar 2, 2024
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 1, 2024

FreeSeqFactory was a construction to demonstrate type safety for certain iterableFactory.from calls where we rely in the fact that for all Seqs iterableFactory has an eager implementation of from.

While that shows that we can make it typesafe, it does not work at runtime as a drop-in replacement for stdlib since of course stdlib does not have a FreeSeqFactory.

This commit drops FreeSeqFactory and adds three unsafeAssumePure calls instead, with explanations.

Fixes #19845

FreeSeqFactory was a construction to demonstrate type safety for certain iterableFactory.from calls
where we rely in the fact that for all Seqs iterableFactory has an eager implementation of from.

While that shows that we _can_ make it typesafe, it does not work at runtime as a drop-in replacement
for stdlib since of course stdlib does not have a FreeSeqFactory.

This commit drop FreeSeqFactory and adds three unsafeAssumePure calls instead, with explanations.

Fixes scala#19745
@odersky odersky requested a review from Linyxus March 1, 2024 19:16
Copy link
Contributor

@Linyxus Linyxus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM!

(edit: I notice there is one the failing test. It seems to be a result of overriding the method apply inside SeqFactory)

// def from[A](source: IterableOnce[A]^): CC[A]
// override def apply[A](elems: A*): CC[A]

// type FreeSeqFactory[+CC[A] <: SeqOps[A, Seq, Seq[A]]] = SeqFactory[CC]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems obsolete. Shall we drop them?

Another method that was added for the typesafety demonstration, which should be removed now.
@Linyxus Linyxus merged commit c7a0459 into scala:main Mar 2, 2024
19 checks passed
@Linyxus Linyxus deleted the fix-19845 branch March 2, 2024 13:42
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
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

Successfully merging this pull request may close these issues.

ClassNotFoundException when running a program compiled with CC Scala 2 library
3 participants