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

Config options that traverse thru F[Elem] are sometimes weird #219

Open
arainko opened this issue Oct 30, 2024 · 0 comments
Open

Config options that traverse thru F[Elem] are sometimes weird #219

arainko opened this issue Oct 30, 2024 · 0 comments

Comments

@arainko
Copy link
Owner

arainko commented Oct 30, 2024

test("Field.fallibleComputedDeep works with F-wrapped values") {
    case class SourceToplevel1(level1: Vector[SourceLevel1])
    case class SourceLevel1(level2: Vector[SourceLevel2])
    case class SourceLevel2(level3: Vector[SourceLevel3])
    case class SourceLevel3(int: Either[List[String], Int])

    case class DestToplevel1(level1: List[DestLevel1])
    case class DestLevel1(level2: List[DestLevel2])
    case class DestLevel2(level3: List[DestLevel3])
    case class DestLevel3(int: Either[List[String], Int])

    val source = SourceToplevel1(Vector(SourceLevel1(Vector(SourceLevel2(Vector(SourceLevel3(Right(1))))))))
    val expected = DestToplevel1(List(DestLevel1(List(DestLevel2(List(DestLevel3(Right(11))))))))

    assertTransformsFallibleConfigured(source, F.pure(expected))(
      Field.fallibleComputedDeep(
        _.level1.element.level2.element.level3.element.int.element,
        (int: Int) => Right(int + 10)
      )
    )
  }

changing line 57 in PathSelector.scala

 case Apply(
              Apply(
                TypeApply(Select(Ident(_), "element"), elemTpe :: _ :: Nil),
                _
              ),
              tree :: Nil
            ) =>
          Logger.debug(s"Matched 'element' of F[Elem] selection", elemTpe.tpe.asType)
          recurse(acc.prepended(Path.Segment.Element(elemTpe.tpe.asType)), tree)

to _ fixes the parsing issue, but the path is still rejected - I'd expect it to work (? to be determined tbh)

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

No branches or pull requests

1 participant