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

LUB of Type<T extends Something> and Type<? extends Something>

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.21, 3.0.16, 4.0.10
    • 2.5.22, 3.0.17, 4.0.11
    • None
    • None

    Description

      Follow up to GROOVY-10756. Blending wildcard and unresolved parameterized type is incomplete.

      Consider the following:

                  interface Handle {
                      int getCount()
                  }
                  class HandleContainer<H extends Handle> {
                      H handle
                  }
                  interface Input {
                      HandleContainer<? extends Handle> getResult(key)
                  }
                  interface State {
                      def <X extends Handle> HandleContainer<X> getResult(key)
                  }
      
                  void test(Input input, State state) {
                      def container = state.getResult('k') ?: input.getResult('k') // HERE: HandleContainer<# extends Handle> and HandleContainer<? extends Handle>
                      Handle handle = container.handle
                      Integer count = handle.count
                      assert count == 1
                  }
      
                  Handle h = {->1}
                  def c = new HandleContainer(handle: h)
                  test({k->c} as Input, {k->c} as State)
      

      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: