From 780e2d8b06fd998b7acd4e320393a747589927c7 Mon Sep 17 00:00:00 2001 From: Bogdan Kolbik Date: Fri, 10 May 2024 17:13:51 +0200 Subject: [PATCH] Inject import --- .../io/moia/protos/teleproto/WriterImpl.scala | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/scala/io/moia/protos/teleproto/WriterImpl.scala b/src/main/scala/io/moia/protos/teleproto/WriterImpl.scala index 61229c6..f98f517 100644 --- a/src/main/scala/io/moia/protos/teleproto/WriterImpl.scala +++ b/src/main/scala/io/moia/protos/teleproto/WriterImpl.scala @@ -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) @@ -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) @@ -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 =