Questions tagged [scalameta]

For meta programming in Scala using the Scalameta library

This tag is for questions relating to the Scalameta library for Scala.

66 questions
0
votes
1 answer

how to append a implicit params use scala meta annotation?

for a example,append a implicit param id for func method: Before def func(p1: String) = { println("hi")} After @Param def func(p1: String)(implicit id: String = "default") = { println("hi")} Is scala meta able do this?
LoranceChen
  • 2,453
  • 2
  • 22
  • 48
0
votes
1 answer

Scalameta inline with maven

I tried to implement scala-meta inline / meta style macro annotation in a scala-maven project. I'm getting following error in the compilation. [ERROR] /home/tiran/.../validatable.scala:12: ';' expected but 'def' found. [ERROR] inline def…
tiran
  • 2,389
  • 1
  • 16
  • 28
0
votes
2 answers

Scala reflect string to singleton object

I'm looking for a way to convert a Scala singleton object given as a string (for example: package1.Main) to the actual instance of Main, so that I can invoke methods on it. Example of the problem: package x { object Main extends App { val…
Devabc
  • 4,782
  • 5
  • 27
  • 40
0
votes
1 answer

Passing type parameter to scala meta macro/annotations

package scalaworld.macros import scala.meta._ class Argument(arg: Int) extends scala.annotation.StaticAnnotation { inline def apply(defn: Any): Any = meta { println(this.structure) val arg = this match { // The argument needs to be…
Bate
  • 23
  • 8
0
votes
1 answer

How do I use Scala-Meta Parse an object?

I am trying to use Scala Meta to write an annotation so I can generate another case class from an existing object. But when I try to do this: MyObject.parse[Source].show[Structure] I got this error: Error:(5, 20) not enough arguments for method…
sowen
  • 1,090
  • 9
  • 28
0
votes
2 answers

Macro annotation to override toString of Scala function

How to write macro annotation which looks in usage like @named("+2") _ + 2 and produces: new (Int => Int) { override def toString(): String = "+2" def apply(x: Int): Int = x + 2 }
Andriy Plokhotnyuk
  • 7,883
  • 2
  • 44
  • 68
1 2 3 4
5