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

Static type checker incorrectly handles assignments of variables used as parameters in control structures

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-beta-2
    • 2.0-beta-3
    • None
    • None

    Description

      Imagine the following code:

      Double foo(Integer x) { x+1 }
      Integer foo(Double x) { x+1 }
      def x = 0
      for (int i=0;i<10;i++) {
         // there are two possible target methods. This is not a problem for STC, but it is for static compilation
         x = foo(x)
      }
      

      The type checker should not allow this to compile. There are more cases (even more complex) like this in the patch (groovy.transform.stc.LoopsSTCTest).

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: