Groovy
  1. Groovy
  2. GROOVY-5384

Type checker doesn't infer generics properly

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta-2
    • Fix Version/s: 2.0-beta-3
    • Component/s: None
    • Labels:
      None

      Description

      In the following code, the computed lowest upper bound of the list doesn't have the correct type.

      class Test {
          static test2() {
              if (new Random().nextBoolean()) {
                  def a = new ArrayList<String>()
                  a << "a" << "b" << "c"
                  return a
              } else {
                  def b = new LinkedList<Number>()
                  b << 1 << 2 << 3
                  return b
              }
          }
      
          static test() {
              def result = test2()
              result[0].toInteger()
              //result[0].toString()
          }
      }
      new Test()
      

        Activity

        Cédric Champeau created issue -
        Cédric Champeau made changes -
        Field Original Value New Value
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12734307 ] Default workflow, editable Closed status [ 12740999 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12967568 ] Default workflow, editable Closed status [ 12975301 ]

          People

          • Assignee:
            Cédric Champeau
            Reporter:
            Cédric Champeau
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development