Designed to reliably work with production releases of the Scala Compiler, the Macro Paradise plugin makes the latest macro developments available long before they end up in future shipping releases of Scala.
Questions tagged [scala-macro-paradise]
77 questions
1
vote
1 answer
scala.meta.Lit.type does not take parameters
When I run the following:
import scala.meta._
class Test {
val x = q"1"
}
I get scala.meta.Lit.type does not take parameters val x = q"1"
scalameta_2.11:1.8.0
paradise_2.11.8:3.0.0-M7
I'm trying to get some basic macro examples working,…

user2682459
- 999
- 2
- 13
- 24
1
vote
2 answers
Scala macro to auto generate fluent builders
I am interacting with an external Java API which looks like this:
val obj: SomeBigJavaObj = {
val _obj = new SomeBigJavaObj(p1, p2)
_obj.setFoo(p3)
_obj.setBar(p4)
val somethingElse = {
val _obj2 = new SomethingElse(p5)
…

pathikrit
- 32,469
- 37
- 142
- 221
1
vote
1 answer
Scala macros: generate code based on file contents
I would like to generate scala classes based on some files.
Placement of the files doesn't matter (it can be resources folder or files can be placed just near my scala source files).
How can I read them when scala macro is executed? (I use…

Eugene Nacu
- 1,613
- 2
- 14
- 22
1
vote
1 answer
Eclipse: Issues resolving implicit conversions and macro annotations in Scala
I'm using macroparadise to generate methods and case classes in my project (the macros themselves are defined in a separate project from my core files where I use them).
Everything compiles and runs as expected, but Eclipse is unable to resolve…

eemc
- 11
- 2
1
vote
1 answer
How to preserve sugar, formatting, and whitespace in macro annotations (inline-meta)?
I'm exporting Scala functions to an external format. For this purpose I use scala.meta and a StaticAnnotation. Something like:
@ExportFunctions
object MyFunctions {
def max(x: Int, y: Int): Int = x max y
}
class ExportFunctions extends…

Arseniy Zhizhelev
- 2,381
- 17
- 21
1
vote
0 answers
Scala macro can't find my java class
I'm creating a scala macro to automatically generate case classes from POJOs (in order to make working with avro a little bit nicer).
Everything "works" except that the compiler - during macro expansion only - chokes on my java class. If I comment…

Marcin
- 48,559
- 18
- 128
- 201
1
vote
2 answers
Scala macro can't find java.util.List, java.lang.Object
Update: see answers below for solution to this problem. There's a second problem (macro now can't find Pojo), question about second problem here: Scala macro can't find my java class
I'm creating a scala macro to automatically generate case classes…

Marcin
- 48,559
- 18
- 128
- 201
1
vote
0 answers
Finding type of a field in enclosing class when expanding a macro annotation on a method
I have a macro annotation dealing with logging, and want to handle both SLF4J and Log4j2 logging. Unfortunately, this requires finding the type of the logger field. I know how to do this when the annotation is on a class from other questions. But I…

Alexey Romanov
- 167,066
- 35
- 309
- 487
1
vote
0 answers
Scala macro annotation expansion order
@Macro
class X {
@AnotherMacro
def y = ...
}
Will the class be transformed first (and able to modify @AnotherMacro) or will the method? Is this guaranteed?

Alexey Romanov
- 167,066
- 35
- 309
- 487
1
vote
1 answer
Can I run a Scala macro automatically when I extend a given type?
Currently, I use a Scala macro annotation to automatically generate some code into a Scala object. It works like this:
@constants
object PopoverCommands extends Constants { … }
I find it somewhat redundant to have to extend Constants and to…

Jean-Philippe Pellet
- 59,296
- 21
- 173
- 234
1
vote
1 answer
easy way to replace term name in ast
I have the following code for:
@compileTimeOnly("enable macro paradise to expand macro annotations")
class replace extends StaticAnnotation {
def macroTransform(annottees: Any*) = macro replaceImpl.replace
}
object replaceImpl {
def replace(c:…

mike
- 749
- 10
- 21
1
vote
1 answer
Provide implicits for all subtypes of sealed type
In my application I have multiple case classes and objects which are part of sealed trait hierarchy. I use them as messages in Akka.
Those classes need to be converted to user friendly form before sending through websocket.
Previously I used big…

Łukasz
- 123
- 1
- 2
- 6
1
vote
1 answer
Is it possible to create a secondary constructor without a macro annotation in Scala?
I would like to create a macro that generates a secondary constructor{'s body). Is it possible to do this without resorting to macro annotations? (i.e. macro-paradise plugin)
For example:
Something like this:
class A(a : String, b : String) {
def…

Králik Barnabás
- 11
- 2
1
vote
1 answer
Is it possible to replace the default apply method generated for case classes in a Scala macro?
It seems like this doesn't work ( Using 2.11.1 and macro paradise 2.0.1).
I was hoping that the case class generated methods would either be suppressed, or be in the tree so I could get rid of it. Is this a hard limitation?
class evis extends…

rjw
- 558
- 3
- 7
1
vote
1 answer
Why is sbt using incorrect version number for declared dependencies?
I have a sbt build file that use 1 plugin and 3 dependencies:
scalaVersion := "2.10.4"
val reflect = Def.setting { "org.scala-lang" % "scala-reflect" % "2.10.4" }
val compiler = Def.setting { "org.scala-lang" % "scala-compiler" % "2.10.4" }
lazy…

tribbloid
- 4,026
- 14
- 64
- 103