scalalandio / chimney

@@ -487,6 +487,8 @@
Loading
487 487
        .groupBy(_.name.toCanonicalName)
488 488
    }
489 489
490 +
  def isCC(s: Symbol): Boolean = s.isCaseClass && !s.isJavaEnum && !s.isModuleClass
491 +
490 492
  def expandSealedClasses(
491 493
      srcPrefixTree: Tree,
492 494
      config: TransformerConfig
@@ -513,11 +515,20 @@
Loading
513 515
                .getOrElse {
514 516
                  toInstances.getOrElse(canonicalName, Nil) match {
515 517
                    case List(matchingTargetSymbol)
516 -
                        if (instSymbol.isModuleClass || instSymbol.isCaseClass) && matchingTargetSymbol.isModuleClass =>
517 -
                      val tree = mkTransformerBodyTree0(config) {
518 -
                        q"${matchingTargetSymbol.asClass.module}"
518 +
                        if matchingTargetSymbol.isModuleClass || matchingTargetSymbol.isJavaEnum =>
519 +
                      val targetTree = mkTransformerBodyTree0(config) {
520 +
                        if (matchingTargetSymbol.isJavaEnum) {
521 +
                          q"$matchingTargetSymbol"
522 +
                        } else {
523 +
                          q"${matchingTargetSymbol.asClass.module}"
524 +
                        }
525 +
                      }
526 +
                      val sourceTree = if (instSymbol.isJavaEnum) {
527 +
                        q"$instSymbol"
528 +
                      } else {
529 +
                        q"$instTpe"
519 530
                      }
520 -
                      Right(cq"_: ${instSymbol.asType} => $tree")
531 +
                      Right(cq"_: $sourceTree => $targetTree")
521 532
                    case List(matchingTargetSymbol) if instSymbol.isCaseClass && matchingTargetSymbol.isCaseClass =>
522 533
                      val fn = freshTermName(instName)
523 534
                      expandDestinationCaseClass(Ident(fn), config.rec)(
@@ -526,24 +537,6 @@
Loading
526 537
                      ).map { innerTransformerTree =>
527 538
                        cq"$fn: $instTpe => $innerTransformerTree"
528 539
                      }
529 -
                    case List(matchingTargetSymbol)
530 -
                        if (instSymbol.isModuleClass || instSymbol.isCaseClass) && matchingTargetSymbol.isJavaEnum => // sealed class may be parameterized
531 -
                      val tree = mkTransformerBodyTree0(config) {
532 -
                        q"$matchingTargetSymbol"
533 -
                      }
534 -
                      Right(cq"_: $instTpe => $tree")
535 -
                    case List(matchingTargetSymbol)
536 -
                        if instSymbol.isJavaEnum && matchingTargetSymbol.isModuleClass => // we do not support mapping from java enum to case classes, only to objects
537 -
                      // it is a bit too much of an effort to support java enum -> case class in general case as case class may carry properties, so we omit this by now
538 -
                      val tree = mkTransformerBodyTree0(config) {
539 -
                        q"${matchingTargetSymbol.asClass.module}"
540 -
                      }
541 -
                      Right(cq"_: $instSymbol => $tree")
542 -
                    case List(matchingTargetSymbol) if instSymbol.isJavaEnum && matchingTargetSymbol.isJavaEnum =>
543 -
                      val tree = mkTransformerBodyTree0(config) {
544 -
                        q"$matchingTargetSymbol"
545 -
                      }
546 -
                      Right(cq"_: $instSymbol => $tree")
547 540
                    case _ :: _ :: _ =>
548 541
                      Left {
549 542
                        Seq(
Files Coverage
chimney/src/main/scala/io/scalaland/chimney 99.42%
Project Totals (25 files) 99.42%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading