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

@Delegate should support including/excluding which methods are delegated to (and optionally complain if multiple exist) - advanced use cases

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.1.0
    • 2.3.0-beta-1
    • groovy-jdk
    • None
    • groovy-2.1.0 on Windows using IDEA IC123.139

    Description

      I have 3 delegate clases:

      class CommonDelegate {
          def String value = "CommonDelegate"
      }
      
      class CommonDelegate2 {
          def String value = "CommonDelegate2"
      }
      
      class CommonDelegate3 {
          def String value = "CommonDelegate3"
      }
      

      and a class Foo:

      class Foo extends CommonDelegate {
      
          @Delegate
          def CommonDelegate2 commonDelegate2 = new CommonDelegate2()
      
          @Delegate
          def CommonDelegate3 commonDelegate3 = new CommonDelegate3()
      
      }
      

      Now, I run this code:

      def Foo foo = new Foo()
      println(foo.getValue())
      

      And this prints "CommonDelegate2"

      Question is now whether @Delegate should complain about the ambiguous call to getValue() in foo.getValue() as people expect @Delegate to be type-safe

      Attachments

        Activity

          People

            paulk Paul King
            oliver_plow Oliver Plow
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: