Skip to content

Conversation

Dolfik1
Copy link

@Dolfik1 Dolfik1 commented May 8, 2025

This commit fixes an issue with decoding recursive case classes in the library. The patch addresses a bug where recursive case classes failed to be parsed correctly from YAML. A test case for a Tree trait with Branch and Leaf case classes was added to demonstrate the fix.

Although I'm not an expert in Scala or metaprogramming, I worked through the problem and implemented a solution based on my understanding.

@tgodzik tgodzik requested a review from lbialy May 8, 2025 09:42
@tgodzik
Copy link
Member

tgodzik commented May 8, 2025

Thanks for the contribution! @lbialy should be able to review, but might be later this month.

Copy link
Member

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Some initial comments while we wait for some review from @lbialy

@@ -577,3 +577,39 @@ class DecoderSuite extends munit.FunSuite:
case Right(value) =>
fail(s"Should fail, but got $value")
}

test("Recursive case class".only) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
test("Recursive case class".only) {
test("Recursive case class") {

this fails on CI

$m: Mirror.SumOf[T] { type MirroredElemTypes = `elementTypes` }
} =>
val instancesExpr = Expr.ofList(summonSumOf[elementTypes])
'{
new YamlDecoder[T] {
private val instances = $instancesExpr.asInstanceOf[List[YamlDecoder[T]]]
private val instances = $instancesExpr.asInstanceOf[List[YamlDecoder[Any]]]
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to change it here?

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.

2 participants