Skip to content

Commit

Permalink
Inject import
Browse files Browse the repository at this point in the history
  • Loading branch information
urmaul committed May 10, 2024
1 parent cb75c94 commit 780e2d8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main/scala/io/moia/protos/teleproto/WriterImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ class WriterImpl(val c: blackbox.Context) extends FormatImpl {
def ask: Compiled = (compileInner(q"implicitly[$writerType]"), Compatibility.full)

if (existingWriter == EmptyTree)
if (checkClassTypes(protobufType, modelType)) {
val (implicitValue, compatibility) = compileClassMapping(protobufType, modelType)
val result = compileInner(implicitValue)
(result, compatibility)
} else if (checkEnumerationTypes(protobufType, modelType)) {
// if (checkClassTypes(protobufType, modelType)) {
// val (implicitValue, compatibility) = compileClassMapping(protobufType, modelType)
// val result = compileInner(implicitValue)
// (result, compatibility)
// } else
if (checkEnumerationTypes(protobufType, modelType)) {
val (implicitValue, compatibility) = compileEnumerationMapping(protobufType, modelType)
val result = compileInner(implicitValue)
(result, compatibility)
Expand All @@ -99,7 +100,7 @@ class WriterImpl(val c: blackbox.Context) extends FormatImpl {
(result, compatibility)
} else {
// look for an implicit transformer
val transformerType = appliedType(c.weakTypeTag[chimney.Transformer[_, _]].tpe, modelType, protobufType)
val transformerType = appliedType(c.weakTypeTag[chimney.Transformer[_, _]].tpe, modelType, protobufType)
val existingTransformer =
try {
c.inferImplicitValue(transformerType)
Expand All @@ -112,7 +113,7 @@ class WriterImpl(val c: blackbox.Context) extends FormatImpl {
def askTransformer = if (existingTransformer != EmptyTree) {
q"implicitly[$transformerType]"
} else {
q"$transformerObj.derive[$modelType, $protobufType]"
q"import io.moia.protos.teleproto.Writer._; $transformerObj.derive[$modelType, $protobufType]"
}

def writerFromTransformer: Compiled =
Expand Down

0 comments on commit 780e2d8

Please sign in to comment.