groovy
  1. groovy
  2. GROOVY-5990 Mixin Issues
  3. GROOVY-5083

Groovy Mixins Can't Satisfy Abstract Class Requirements

    Details

    • Type: Sub-task Sub-task
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.8.0, 1.8.3
    • Fix Version/s: None
    • Component/s: groovy-runtime
    • Labels:
    • Environment:
      OS X 10.7.2
    • Number of attachments :
      0

      Description

      Using the mixin annotation I can add mixins to classes, however those mixins cannot fulfill abstract class requirements. For example, the following code throws compilation exceptions:

      class M

      { def foo = 11 def bar = 12 }

      abstract class A

      { abstract foo }

      @Mixin(M)
      class B extends A {
      }

      def b = new B()
      print "$

      {b.foo}

      \n"
      print "$

      {b.bar}

      \n"

      When attempting to run this code I get:

      /private/tmp/runner.groovy: 10: Can't have an abstract method in a non-abstract class. The class 'B' must be declared abstract or the method 'java.lang.Object getFoo()' must be implemented.
      @ line 10, column 1.
      @Mixin(M)
      ^

      /private/tmp/runner.groovy: 10: Can't have an abstract method in a non-abstract class. The class 'B' must be declared abstract or the method 'void setFoo(java.lang.Object)' must be implemented.
      @ line 10, column 1.
      @Mixin(M)
      ^

      2 errors

        Activity

        Hide
        Pascal Schumacher added a comment -

        I'm closing this as "Won't Fix" because as of Groovy 2.3 @Mixin was deprecated. Please consider using traits instead.

        Show
        Pascal Schumacher added a comment - I'm closing this as "Won't Fix" because as of Groovy 2.3 @Mixin was deprecated. Please consider using traits instead.

          People

          • Assignee:
            Unassigned
            Reporter:
            Matt Follett
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: