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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.0
    • Fix Version/s: 2.3.0-beta-1
    • Component/s: groovy-jdk
    • Labels:
      None
    • Environment:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: