Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5990 Mixin Issues
  3. GROOVY-5083

Groovy Mixins Can't Satisfy Abstract Class Requirements

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: 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

      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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: