Closed chipsenkbeil closed 7 years ago
Update in that now it compiles to the same level with 2.10, 2.11, and 2.12.
Still can't get the compiler to recognise my filled in methods. Considering only generated code is referencing the generated class, I would have thought it would work. Am I not understanding something correctly?
Figured it out. I was creating the methods and implementing their bodies, but reusing the old modifiers of each method and just tacking on the Flag.OVERRIDE: FlagSet
. Turns out unimplemented methods have a Flag.DEFERRED
on them, so I was producing a Modifiers(OVERRIDE | DEFERRED)
, which didn't make sense considering it had a body.
My problem is that my generated class' members are not getting recognised as implemented. This is currently using Scala 2.10, but I plan to refactor it for 2.11/2.12 once I get this implementation working. Using macroparadise 2.10.
Goal of this was to mark the some traits as freezable and generate an implementation class for each that takes
scala.util.Try
for each method that is freezable that will have itsget
method called when accessing the data. All unfreezable methods are filled in withthrow new IllegalStateException
. And a customfreeze
method is created that creates an instance of theFrozen
class filled in with the data needed using the methods defined by the trait.I have set up an annotation macro to be placed on traits and generate a companion object with an inner class called
Frozen
like below:The following error occurs when I try to run my macro on the trait
JavaInfo
:The trait itself is as follows:
Get error that nothing has been implemented by the
Frozen
class, even though I see the implementation in the tree I'm building.Code in question is here: https://github.com/chipsenkbeil/scala-debugger/blob/AddFreezableMacroSupport/scala-debugger-macros/src/main/scala/org/scaladebugger/macros/freeze/Freezable.scala
You can test the failure by checking out that branch and running
sbt scalaDebuggerApi/compile
, which will compile the macros project for Scala 2.10 followed by the API itself.