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

Fix ClassCastException on import given #472

Merged
merged 4 commits into from Mar 20, 2023
Merged

Fix ClassCastException on import given #472

merged 4 commits into from Mar 20, 2023

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Mar 20, 2023

Fixes #469

The basic problem is that superTypeReader and superTypeWriter were triggering for Types T and V which were identical, meaning it was getting used even when not necessary due to import upickle.default.given increasing its implicit priority.

This PR adds a : SumOf implicit requirement to V, ensuring that superTypeReader and superTypeWriter only trigger when V is a parent sealed trait/class/enum type, won't trigger when T =:= V as a case class, and thus the .asInstanceOf[TaggedReader[T]] cast is valid

@lihaoyi lihaoyi marked this pull request as ready for review March 20, 2023 07:02
@lihaoyi lihaoyi merged commit 09d118b into main Mar 20, 2023
8 checks passed
@lefou lefou added this to the 3.1.0 milestone Mar 20, 2023
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.

class upickle.core.Types$$anon$3 cannot be cast to class upickle.core.Types$TaggedReader
2 participants