Comments (1)
Hello!
Sorry for the late answer but I am on my vacations and I don't hang around GH, emails and other work-related stuff too often.
I'd say that the problem's you have described are real, but also they are something I had I think with virtually every other macro annotation:
knownDirectSubclasses
is very reliant on compilation order and I usually resolved it by shuffling the other of classes and companions until it works (and I mean here also other annotations like@JsonCodec
from Circe)- I had issues in the past when something started/stopped working locally after reordering and it was completely different on CI or after clean because incremental compiler's cache was a mess.
As for the suggestion of adding ability to annotate companion object directly I could take a look at this, but it could be difficult. There is basically a reason why not so many macro annotations for adding implicits works this way:
- when you add annotation on class, in macro I receive a list of ASTs:
- if class has no companion, it is
classAST :: Nil
, - if class has companion it is either
classAST :: companionAST :: Nil
orcompanionAST :: classAST :: Nil
- if class has no companion, it is
- then I do pattern matching on it, and use class to extract class information (e.g. FQCN) and I use companion to inject implicits (or create it if it wasn't there)
- but if I annotate object I receive only object's AST. And it's type is different that classes type. So I would probably have to:
- turn object's type to name , e.g
MyCompanion.type
- remove
.type
suffix - typecheck this string (which would increase the cost of compilation)
- if type is found then use it to generate macro
- turn object's type to name , e.g
It is definitely doable, but would require some hairy logic and a lot of testing. For the next few weeks I will stay off any work-related stuff but if you are interested in making a pull request and working on it I could log-in once in a while to help.
from catnip.
Related Issues (9)
- Local imports and type aliases
- Add support for Scala 2.13 and cats 2.0.0 HOT 2
- Update dependencies (scala-steward?)
- Cross-compile for Scala.js and other Scala versions
- Publish on Sonatype HOT 1
- Support cases where more type-classes are needed for type-parametrized derivation
- Cannot run tests on cloned project HOT 4
- Add support for `cats.kernel.Hash` HOT 5
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 catnip.