Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6654

Can't @Override method with generic argument type in parameterized subclass

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.0-beta-1
    • 2.3.0-beta-1
    • Compiler
    • None

    Description

      Base.groovy

      class Base<T> {
        void foo(T t) {}
      }
      

      Derived.groovy

      class Derived extends Base<String> {
        @Override
        void foo(String s) {}
      }
      

      Compile error:

      Error:(2, 3) Groovyc: Method 'foo' from class 'Derived' does not override method from its superclass or interfaces but is annotated with @Override.
      

      Removing the @Override annotation appears to solve the problem. Earlier Groovy versions (e.g. 2.0.x) didn't have this problem. Tested with latest groovy-all-2.3.0-SNAPSHOT.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            melix Cédric Champeau
            pniederw Peter Niederwieser
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment