Giter Site home page Giter Site logo

Comments (1)

MateuszKubuszok avatar MateuszKubuszok commented on September 24, 2024

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 or companionAST :: classAST :: Nil
  • 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

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.