Skip to content

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
@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