#197 WIP Resolving TransformerF and Transformer ambiguity

Open Ilya Ulanov ulanzetz

@@ -757,16 +757,19 @@
Loading
757 757
758 758
      (implicitTransformerF, implicitTransformer) match {
759 759
        case (Some(localImplicitTreeF), Some(localImplicitTree)) =>
760 -
          c.abort(
761 -
            c.enclosingPosition,
762 -
            s"""Ambiguous implicits while resolving Chimney recursive transformation:
760 +
          if (config.flags.preferPureTransformer)
761 +
            Right(TransformerBodyTree(localImplicitTree.callTransform(srcPrefixTree), isWrapped = false))
762 +
          else
763 +
            c.abort(
764 +
              c.enclosingPosition,
765 +
              s"""Ambiguous implicits while resolving Chimney recursive transformation:
763 766
               |
764 767
               |TransformerF[${config.wrapperType.get}, $From, $To]: $localImplicitTreeF
765 768
               |Transformer[$From, $To]: $localImplicitTree
766 769
               |
767 770
               |Please eliminate ambiguity from implicit scope or use withFieldComputed/withFieldComputedF to decide which one should be used
768 771
               |""".stripMargin
769 -
          )
772 +
            )
770 773
        case (Some(localImplicitTreeF), None) =>
771 774
          Right(TransformerBodyTree(localImplicitTreeF.callTransform(srcPrefixTree), isWrapped = true))
772 775
        case (None, Some(localImplicitTree)) =>

@@ -141,7 +141,8 @@
Loading
141 141
      beanSetters: Boolean = false,
142 142
      beanGetters: Boolean = false,
143 143
      optionDefaultsToNone: Boolean = false,
144 -
      unsafeOption: Boolean = false
144 +
      unsafeOption: Boolean = false,
145 +
      preferPureTransformer: Boolean = false
145 146
  ) {
146 147
    def setFlag(flagTpe: Type, value: Boolean): TransformerFlags = {
147 148
      if (flagTpe =:= FlagsTpes.methodAccessorsT) {
@@ -156,6 +157,8 @@
Loading
156 157
        copy(optionDefaultsToNone = value)
157 158
      } else if (flagTpe =:= FlagsTpes.unsafeOptionT) {
158 159
        copy(unsafeOption = value)
160 +
      } else if (flagTpe =:= FlagsTpes.preferPureTransformerT) {
161 +
        copy(preferPureTransformer = value)
159 162
      } else {
160 163
        // $COVERAGE-OFF$
161 164
        c.abort(c.enclosingPosition, s"Invalid transformer flag type: $flagTpe!")
@@ -178,6 +181,7 @@
Loading
178 181
    val beanGettersT: Type = typeOf[BeanGetters]
179 182
    val optionDefaultsToNoneT: Type = typeOf[OptionDefaultsToNone]
180 183
    val unsafeOptionT: Type = typeOf[UnsafeOption]
184 +
    val preferPureTransformerT: Type = typeOf[PreferPureTransformer]
181 185
  }
182 186
183 187
  def captureTransformerFlags(

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
chimney/src/main/scala/io/scalaland/chimney +<.01% 99.56%
Project Totals (25 files) 99.56%
Loading