We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import scala.reflect.macros.Context import language.experimental.macros object Macros { def getValueImpl[T](c: Context): c.Expr[T] = { import c.universe._ c.Expr[T](Apply(Select(c.prefix.tree, newTermName("getVal")), Nil)) } def setValueImpl[T](c: Context)(value: c.Expr[T]): c.Expr[Unit] = { import c.universe._ c.Expr[Unit](Apply(Select(c.prefix.tree, newTermName("setVal")), List(value.tree))) } }
object Test extends App { object Module { def setVal(value: String): Unit = ??? def getVal(): String = ??? def value: String = macro Macros.getValueImpl[String] def value_=(value: String): Unit = macro Macros.setValueImpl[String] } Module.value = "" }
The text was updated successfully, but these errors were encountered:
Imported From: https://issues.scala-lang.org/browse/SI-7617?orig=1 Reporter: @xeno-by Affected Versions: 2.10.2, 2.11.0-M3
Sorry, something went wrong.
@xeno-by said: Along the same lines:
import scala.reflect.macros.Context import language.experimental.macros object Macros { def impl(c: Context)(name: c.Expr[String])(value: c.Expr[Any]) = { import c.universe._ reify(println(s"${name.splice} = ${value.splice}")) } }
import scala.language.dynamics class C extends Dynamic { def updateDynamic(name: String)(value: Any) = macro Macros.impl } object Test extends App { val c = new C c.foo = 2 }
16:54 ~/Projects/Kepler_7617/sandbox (ticket/7617)$ ss Test.scala:9: error: macros cannot be partially applied c.foo = 2 ^ one error found
@xeno-by said: scala/scala#2689
xeno-by
No branches or pull requests
The text was updated successfully, but these errors were encountered: