1

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, specifically the "Hello" example found here:

https://www.beyondthelines.net/computing/generating-protobuf-formats-with-scala-meta-macros/

Where I get the same error on the "val hello ...." line

Any thoughts/suggestions would be greatly appreciated - I'm really excited to have a play with macros!

user2682459
  • 999
  • 2
  • 13
  • 24

1 Answers1

0

You should wrap your code with inline & meta, just like in your example.

If you just want to analyze what meta does, you could type <code>.parse[Type / Stat]

dveim
  • 3,381
  • 2
  • 21
  • 31
  • That doesn't work. Maybe I wasn't clear enough in the question but it doesn't work for the example from the website either – user2682459 Apr 23 '18 at 17:23
  • Did you install 'paradise' compiler plugin? – dveim Apr 24 '18 at 13:54
  • I believe so; is there an easy way to check this has happened properly? – user2682459 Apr 24 '18 at 14:09
  • You should have smth like in sbt definition (if you use sbt) `addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)` – dveim Apr 24 '18 at 14:17
  • No, sadly I need to use gradle instead of SBT. I believe paradise is being included, but I'm not sure how to check everything has been properly applied... Is there anything programatically I can do to test if paradise is there? – user2682459 Apr 24 '18 at 17:18
  • I have added the "-Xplugin-require:macroparadise" to tasks.withType(ScalaCompile) ; if I misspell macroparadise then the build fails with a sensible error which suggests that the plugin is being added otherwise – user2682459 Apr 24 '18 at 17:23
  • Unfortunately, I'm not familiar with gradle. This project, `https://github.com/vergenzt/rtm-scala`, uses macro paradise, so you might want to clone it, verify that macros work, and then add your stuff. – dveim Apr 25 '18 at 08:43