Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,12 @@ private[ducktape] object Plan {
Quotes,
Context
): Plan.Configured[F] =
(plan.source.tpe, plan.dest.tpe, conf.tpe) match {
case ('[src], '[dest], '[confTpe]) =>
val source = if instruction.side.isDest then Structure.Lazy.of[confTpe](plan.source.path) else plan.source
conf.tpe match {
case '[confTpe] =>
// if side is Source then we're operating on either a missing Source case or an override of that,
// which means the dest types need to be narrowed down to the exact type of this config
val dest = if instruction.side.isSource then Structure.Lazy.of[confTpe](plan.dest.path) else plan.dest
Plan.Configured(source, dest, conf, instruction.span)
Plan.Configured(plan.source, dest, conf, instruction.span)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private[ducktape] object PlanInterpreter {
plan match {
case Plan.Upcast(_, _, _) => value

case Plan.Configured(_, _, config, _) =>
case Plan.Configured(_, dest, config, _) =>
evaluateConfig(config, value)

case Plan.BetweenProducts(sourceTpe, destTpe, fieldPlans) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.github.arainko.ducktape.issues

import io.github.arainko.ducktape.*

class Issue211Suite extends DucktapeSuite {
test("directly configuring a Dest case doesn't fail at runtime") {
enum SourceLevel3 {
case One(int: Int)
case Two(str: String)
}

enum DestLevel3 {
case One(int: Long)
case Two(str: String)
}

val source = SourceLevel3.One(1)
val expected = DestLevel3.One(6)

assertTransformsConfigured(source, expected)(
Field.const(_.at[DestLevel3.One], DestLevel3.One(6L))
)
}
}