You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code below, the macro doesn't override an abstract method, because it is defined in class A. Still, the compiler thinks it's abstract.
Welcome to Scala version 2.11.0-M3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import language.experimental.macros
import language.experimental.macros
scala> trait T { def t(): Unit }
defined trait T
scala> abstract class A extends T { override def t(): Unit = () }
defined class A
scala> import scala.reflect.macros.Context
import scala.reflect.macros.Context
scala> object Macro { def t(c: Context)(): c.Expr[Unit] = c.universe.reify(()) }
defined object Macro
scala> class C extends A { override def t(): Unit = macro Macro.t }
<console>:12: error: overriding method t in trait T of type ()Unit;
macro method t cannot be used here - term macros cannot override abstract methods
class C extends A { override def t(): Unit = macro Macro.t }
The text was updated successfully, but these errors were encountered:
In the code below, the macro doesn't override an abstract method, because it is defined in class A. Still, the compiler thinks it's abstract.
The text was updated successfully, but these errors were encountered: