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 Bug
    • Status: Closed Closed
    • Priority: Minor 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
    • Number of attachments :
      0

      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

        Activity

        Hide
        Paul King added a comment -

        Cloned from GROOVY-5974 to handle advanced use cases as discussed in that issue.

        Show
        Paul King added a comment - Cloned from GROOVY-5974 to handle advanced use cases as discussed in that issue.
        Hide
        Paul King added a comment -

        Now handles includeTypes and excludeTypes similar to Lombok (with basic generics support)

        Show
        Paul King added a comment - Now handles includeTypes and excludeTypes similar to Lombok (with basic generics support)

          People

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

            Dates

            • Created:
              Updated:
              Resolved: