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

AutoImplement and method with default arguments

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-9
    • None
    • None

    Description

      Consider the following:

      interface I {
        def foo(bar)
        def foo(bar,baz)
        // ...
      }
      @groovy.transform.AutoImplement
      class C implements I {
        @Override // foo(bar) and foo(bar,baz)
        def foo(bar, baz = null) {
        }
      }
      

      We want to auto-implement most of I but explicitly provide an implementation for both foo methods. Compiler says "The method with default parameters "java.lang.Object foo(java.lang.Object, java.lang.Object)" defines a method "java.lang.Object foo(java.lang.Object)" that
      is already defined."

      Defining the overrides separately (no default generated method) works fine.

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: