Comments (4)
The issue is similar to what is done in https://github.com/scalalandio/chimney/blob/master/chimney-protobufs/src/test/scala/io/scalaland/chimney/ProtobufOneOfSpec.scala#L13 - PB arbitrarily decides what to wrap and what to pass straight forcing users to wrap/unwrap in arbitrary places.
This would require change in macros which would test if something is wrapper and unwrap automatically even if the type is not an AnyVal
which is kinda ugly - I'd allow such thing only with a flag as this could generate some subtle bugs and increase the compilation time.
from chimney.
Maybe only check if the inner type is a scalapb.GeneratedOneof
?
I agree with you, it's quite ugly and unfortunate that scalapb doesn't give us a better way to do that 🤔
from chimney.
Maybe only check if the inner type is a scalapb.GeneratedOneof?
That would require making the core, dependency-free, module dependent on some external implementation. Or introducing a way of injecting extensions into makro with some type classes and implicits.
Maybe some workaround like:
implicit def transformAndWrap[
From,
To <: scalapb.GeneratedMessage,
ToValue <: scalapb.GeneratedOneof
](
implicit transformer: Transformer.AutoDerived[From, ToValue],
// shapeless.HList or Mirror.ProductOf as evidence + constructor
// e.g. Generic.Aux[To, ToValue :: HNil]
// or Mirror.ProductOf[To] { type MirrorElementTypes = ToValue +: EmptyTuple }
): Transformer[From, To] =
src => {
val value = transformer.transform(src)
// wrap value using shapeless/mirror
}
would pass in the meantime.
from chimney.
Related Issues (20)
- Unexpected arity mismatch when mixing Tuple with `enableOptionDefaultsToNone` HOT 6
- Improve ReadTheDocs/MkDocs configuration
- Scary compiler error when providing Int const instead of Long HOT 3
- Compilation of partial transformation fails when there are fields named both `is{Name}` and `{name}` HOT 2
- Silent invalid behavior of `withFieldConst` when field name starts with "set" HOT 6
- [PartialTransformer] Field Option[Field].None to Proto3.Fields.Default
- ClassCastException thrown on Scala 3 when transforming sealed traits to Protobuf GeneratedEnum HOT 12
- Automatic Coproduct Rename from/to Protobuf GeneratedEnum HOT 8
- Can't transform coproduct - Java Enum to Sealed trait HOT 24
- Cannot transform Scala class to Java class HOT 5
- Chimney stabilization into 1.0.0
- Exclude macro generated code from WartRemover checks HOT 14
- Fix Overrides for Subtypes matching
- Compiler bugs: known, relevant and unresolved/undocumented
- Support transformation to and from Java primitives
- Test more Scala CLI snippets for output (printed results)
- Support runtime-defined enums
- Rewrite Patchers as a special case of multiple case classes mapping
- Refactor internals to NOT rely on RuntimeDataStore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chimney.