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

Cannot loop using foreach or "for in" in @TypeChecked code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.1
    • Static Type Checker
    • java version "1.7.0_05"
      Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)

      Windows 7 Home Premium

    Description

          @Test
          @TypeChecked
          void testForEach() {
              int i = 0;
              for (Field field : String.class.declaredFields) {
                  i++;
              }
              assert i > 0
          }
      

      fails on compile time with

      [Static type checking] - Cannot loop with element of type java.lang.reflect.Field -> java.lang.reflect.Field with collection of type java.lang.ref.SoftReference <T extends java.lang.Object -> java.lang.Object>

      Attachments

        1. IteratorTest.groovy
          0.6 kB
          Nikolay Plekhanov

        Activity

          People

            melix Cédric Champeau
            nplekhanov Nikolay Plekhanov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: