Skip to content

Instantly share code, notes, and snippets.

@majk-p
Created December 15, 2023 14:03
Show Gist options
  • Save majk-p/2ce290d9dfd0dc9f56960bddbde4c41e to your computer and use it in GitHub Desktop.
Save majk-p/2ce290d9dfd0dc9f56960bddbde4c41e to your computer and use it in GitHub Desktop.
Workaround for "Scala211 doesn't support inline modifiers" when printing scala meta tree and weaver
//> using scala "2"
//> using dep "org.scalameta::scalameta:4.8.14"
//> using test.dep "com.disneystreaming::weaver-cats:0.8.3"
//> using testFramework "weaver.framework.CatsEffect"
import cats.Eq
import cats.Show
import weaver._
import scala.meta._
import scala.meta.contrib._
import scala.meta.dialects.Scala3
object Codegen {
def codeWithInline =
source"""
object Generated {
inline def dummy = scala.compiletime.error("this method shuold not be invoked")
}
"""
}
object SampleSpec extends FunSuite {
val result = Codegen.codeWithInline
test("Should generate code with inline") {
val expectation = source"""
object Generated {
inline def dummy = scala.compiletime.error("DIFFERENT MESSAGE TO FAIL TEST")
}
"""
implicit def catsKernelEqScalaMetaTree[T <: Tree]: Eq[T] =
(a: T, b: T) => a.isEqual(b)
implicit val showTree: Show[Source] = _.syntax
expect.eql(result, expectation)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment