Questions tagged [scala-macro-paradise]

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.

77 questions
2
votes
2 answers

Macros annotation not working in IntelliJ14

I am having trouble using Scala Macros. It keeps on telling me to enable macro paradise to expand macro annotations from the @compileTimeOnly message I wrote. I followed all the instructions from Macro annotation documentation and the SBT…
user1187135
2
votes
1 answer

enable macro paradise to expand macro annotations

I wanted to check some examples with annotations in macro paradise and I am getting the error, as is specified in: this example I have related the projects, the other scala macros (not with annotations) are working very well. I have included the…
Avah
  • 227
  • 3
  • 13
2
votes
1 answer

Is it possible to have macro annotation parameters (and how to get them)?

I have some data source that requires wrapping operations in transactions, which have 2 possible outcomes: success and failure. This approach introduces quite a lot of boilerplate code. What I'd like to do is something like this (the same remains…
tkroman
  • 4,811
  • 1
  • 26
  • 46
2
votes
0 answers

How do I extract primary constructor params with a quasiquote

I'm currently using: annottees map (_.tree) match { case (classDef @ q"$mods class $tpname[..$tparams] $ctorMods(...$paramss) extends { ..$earlydefns } with ..$parents { $self => ..$stats }") :: Nil => to extract both the classDef and the…
2
votes
1 answer

How can I specify the order of macro annotation expansion of multiple classes?

Suppose I've got two macro-annotated classes, and after their fields are defined during expansion, one depends on the other: @Annotation case class A(i: Int) @Annotation case class B(a: A) I need A to be expanded before B, but the order of their…
Julian Peeters
  • 853
  • 1
  • 6
  • 19
2
votes
1 answer

Is there anyway to go from a Symbol or Type to a Tree when defining a Scala macro

Is there anyway to go from a Symbol or Type to a Tree when defining a Scala macro? Specifically the scenario is wanting to look up a literal on a companion object. In scala code this looks something like this: class Fred(a: String) object Fred { …
see
  • 43
  • 3
2
votes
1 answer

how to define a type alias for a higher kinded type by a scala macro annotation (preferably using quasiquotes)

I develop a scala macro annotation that enriches objects with various definitions (cf. play form macro). Amongst other things I want that the object contains the type alias type WFS = FS[_, _, _, _] for a varying number of wildcard arguments. I…
Stefan
  • 207
  • 2
  • 8
2
votes
1 answer

Apart from macro annotations, what macro creation methods avoid immediate type checking?

Since untyped macros are out, the number of macro variants that avoid initial type checking has been diminished. The rationale in the relevant release doc references both implicit macros and macro annotations as alternatives. And indeed macro…
mikołak
  • 9,605
  • 1
  • 48
  • 70
1
vote
1 answer

Scala macros/paradise case class apply method

I'm working on Scala 2.12.17. Let's say I've a bunch of case classes : case class TestOne(one: String) case class TestTwo(one: String, two: String) case class TestThree(one: String, two: String, three: String) I also have these types : trait…
Fragan
  • 792
  • 10
  • 29
1
vote
1 answer

How to obtain complex type in scala macro?

I have following macro, which is constucting some Field class for given accessor of source class: case class Field[S, F](name: String, lens: Lens[S, F]) class Fields[S] { def field[D](property: S => D): Field[S, D] = macro FieldsMacro.impl[S,…
Niko Demin
  • 109
  • 1
  • 9
1
vote
0 answers

Using existing methods in macro

Suppose i have some class with some methods class Clz ... { def someMethod: Map[String, Long] = ... def id: Long = 0L } i'm need to reuse someMethod and overwrite id i don't know why but it's throw Stackoverflow and also i'm need to do…
1
vote
1 answer

Make Scala class extends trait/abstract class with macros

The problem: I want to make the annotated class a subclass of another class with scala macro What I have: Wrapper for fields: class Field(fieldType: DbModelFieldType, fieldName: String) An abstract class (base class for all annotated…
1
vote
1 answer

Cats-tagless - Scala macro annotation error

I have created a simple trait using cats-tagless lib: @finalAlg @autoFunctorK(true) trait MyService[F[_]] { def put(element: Element): F[Element] def get(elementId: Id): F[Element] def all(): F[List[Element]] def delete(elementId: Id):…
Developus
  • 1,400
  • 2
  • 14
  • 50
1
vote
1 answer

Does macroparadise no longer work from the command line?

I am trying to start using the paradise macro plugin, so I have been beginning with the identity macro example from: https://docs.scala-lang.org/overviews/macros/annotations.html However, when I try to use the identity annotation I get error:…
1
vote
1 answer

Workaround for Scala macro annotation bug

I have a macro annotation that I use to inject implicit type class to a companion method. @MyMacro case class MyClass[T](a: String, b: Int, t: T) Most of the time it work as expected, but it breaks when I use type constraint notation: @MyMacro case…
Mateusz Kubuszok
  • 24,995
  • 4
  • 42
  • 64