简体   繁体   中英

Simulacrum: macro implementation not found

I've got a simple code in Scala to try simulacrum lib:

import simulacrum._
@typeclass trait Semigroup[A] {
  @op("|+|") def append(x: A, y: A): A
}

But this doesn't work. Compiler says

Error:(3, 2) macro implementation not found: macroTransform (the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them) @typeclass trait Semigroup[A] {

What can cause this error? I do not create a macro, I just reuse an existing one.

My build.sbt file is simple:

name := "Macr"
version := "0.1"
scalaVersion := "2.12.5"
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
libraryDependencies += "com.github.mpilquist" %% "simulacrum" % "0.12.0"

As noted by Oleg Pyzhcov in the comments, macros don't work with Scala 2.12.4 and 2.12.5 when compiling on Java 9 or 10 . However, this has been fixed in Scala 2.12.6 , so upgrading should solve the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM