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

STC: return type for unresolved placeholder with bound resolved to Object

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-beta-1, 2.5.16, 3.0.10
    • None
    • None

    Description

      Follow up from GROOVY-9033. Consider the following:

      abstract class State<H extends Handle> {
          // Why not return HandleContainer<H>? I can't really say.
          def <T extends Handle> HandleContainer<T> getHandleContainer(key) {
          }
      }
      class HandleContainer<H extends Handle> {
          H handle
      }
      interface Handle {
          Result getResult()
      }
      class Result {
          int itemCount
          String[] items
      }
      
      List<String> getStrings(State state, List keys) {
          keys.collectMany { key ->
              List<String> strings = Collections.emptyList()
              def container = state.getHandleContainer(key) // returns HandleContainer<Object> not HandleContainer<Handle>
              if (container != null) {
                  def result = container.handle.result
                  if (result != null && result.itemCount > 0) {
                      strings = Arrays.asList(result.items)
                  }
              }
              strings
          }
      }
      

      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: