Scala Programming Language
  1. Scala Programming Language
  2. SI-7657

Macros cannot override concrete method which overrides an abstract one

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.11.0-M3, Scala 2.11.0-M4
    • Fix Version/s: Scala 2.10.3-RC1
    • Component/s: Macros
    • Environment:

      MacOS 10.8, Java 7

      Description

      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 }

      ```

        Activity

        Show
        Eugene Burmako added a comment - https://github.com/scala/scala/pull/2730
        Show
        Eugene Burmako added a comment - Fixed in https://github.com/scala/scala/commit/ef979c02da887b7c56bc1da9c4eb888e92af570f

          People

          • Assignee:
            Eugene Burmako
            Reporter:
            Heiko Seeberger
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development