2018-01-13から1日間の記事一覧

Scalaマクロのerrorとabortの違い

Scalaのマクロで、コンパイルエラーにしてしまうときは Context.error を使う。 def someMethod_impl(c: Context)(arg: c.Expr[String]): c.Expr[Unit] = { // ... if (cond) { c.error(c.enclosingPosition, "a message") } // ... } でもこれが微妙に使い…