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

Consider supporting property syntax for variadic "getter" methods

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      Consider the following:

      @groovy.transform.TypeChecked
      class C {
        def getFoo(String[] strings) {
        }
        void test() {
          getFoo()
          foo
        }
      }
      
      @groovy.transform.TypeChecked
      void test(Class<?> type) {
        type.getDeclaredConstructor().newInstance() // getDeclaredConstructor(Class...)
        type.declaredConstructor.newInstance()
      }
      

      Since "getFoo" can be called with zero arguments, does that make it a candidate for supporting property syntax? I submit this for consideration.

      We have style checks that suggest property syntax when "getName()" is encountered. But this case cannot be converted and so we must live with a warning or add an exclusion.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated: