Skip to content

Fix ClassCastException on import given#472

Merged
lihaoyi merged 4 commits intomainfrom
infinite-loop
Mar 20, 2023
Merged

Fix ClassCastException on import given#472
lihaoyi merged 4 commits intomainfrom
infinite-loop

Conversation

@lihaoyi
Copy link
Copy Markdown
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
@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