Skip to content
New issue

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

Macros cannot override concrete method which overrides an abstract one #7657

Closed
scabug opened this issue Jul 13, 2013 · 3 comments
Closed

Macros cannot override concrete method which overrides an abstract one #7657

scabug opened this issue Jul 13, 2013 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jul 13, 2013

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 }
@scabug
Copy link
Author

scabug commented Jul 13, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7657?orig=1
Reporter: @hseeberger
Affected Versions: 2.11.0-M3, 2.11.0-M4

@scabug
Copy link
Author

scabug commented Jul 14, 2013

@xeno-by said:
scala/scala#2730

@scabug
Copy link
Author

scabug commented Jul 22, 2013

@xeno-by said:
Fixed in scala/scala@ef979c0

@scabug scabug closed this as completed Jul 22, 2013
@scabug scabug added this to the 2.10.3-RC1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants