Skip to content

Commit

Permalink
fix: use fully qualified types in macros (#5434)
Browse files Browse the repository at this point in the history
  • Loading branch information
RustedBones authored Jul 24, 2024
1 parent ab6eef6 commit 714a5a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,12 @@ final class CoderTest extends AnyFlatSpec with Matchers {
)
}

it should "derive when protobuf Any is in scope" in {
"""import com.google.protobuf.Any
|Coder.gen[DummyCC]
|""".stripMargin should compile
}

it should "support classes with private constructors" in {
import com.spotify.scio.coders.kryo.{fallback => f}
PrivateClass(42L) coderShould fallback() and materializeTo[KryoAtomicCoder[_]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ private[scio] object MagnoliaMacros {
// format: off
// Remove annotations from magnolia since they are
// not serializable and we don't use them anyway
val empty = q"_root_.scala.Array.empty[_root_.scala.Any]"
val removeAnnotations: PartialFunction[Tree, Tree] = {
case q"$caseClass($typeName, $isObject, $isValueClass, $parametersArray, $_, $_, $_)" if caseClass.symbol.name == TypeName("CaseClass") =>
q"$caseClass($typeName, $isObject, $isValueClass, $parametersArray, Array.empty[Any], Array.empty[Any], Array.empty[Any])"
q"$caseClass($typeName, $isObject, $isValueClass, $parametersArray, $empty, $empty, $empty)"
case q"Param.apply[$tpTC, $tpT, $tpP]($name, $typeNameParam, $idx, $isRepeated, $typeclassParam, $defaultVal, $_, $_, $_)" =>
q"_root_.magnolia1.Param[$tpTC, $tpT, $tpP]($name, $typeNameParam, $idx, $isRepeated, $typeclassParam, $defaultVal, Array.empty[Any], Array.empty[Any], Array.empty[Any])"
q"_root_.magnolia1.Param[$tpTC, $tpT, $tpP]($name, $typeNameParam, $idx, $isRepeated, $typeclassParam, $defaultVal, $empty, $empty, $empty)"
case q"new SealedTrait($typeName, $subtypesArray, $_, $_, $_)" =>
q"new _root_.magnolia1.SealedTrait($typeName, $subtypesArray, Array.empty[Any], Array.empty[Any], Array.empty[Any])"
q"new _root_.magnolia1.SealedTrait($typeName, $subtypesArray, $empty, $empty, $empty)"
case q"Subtype[$tpTC, $tpT, $tpS]($name, $idx, $_, $_, $_, $tc, $isType, $asType)" =>
q"_root_.magnolia1.Subtype[$tpTC, $tpT, $tpS]($name, $idx, Array.empty[Any], Array.empty[Any], Array.empty[Any], $tc, $isType, $asType)"
q"_root_.magnolia1.Subtype[$tpTC, $tpT, $tpS]($name, $idx, $empty, $empty, $empty, $tc, $isType, $asType)"
}

// remove all outer references used in rawConstruct
Expand Down

0 comments on commit 714a5a2

Please sign in to comment.