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

Missing temporary type information check if a receiver has a property with generics

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2, 2.3.0-rc-1
    • Fix Version/s: 2.3.0-rc-2, 2.2.3
    • Component/s: None
    • Labels:
      None

      Description

      The following code fails to compile:

      class Foo {
          List<String> items = []
      }
      
      @groovy.transform.CompileStatic
      void m(Object o) {
          if (o instanceof Foo) {
              assert o.items.empty
          }
      }
      

      error:

      UG! exception in phase 'instruction selection' in source unit 'ConsoleScript1' Declaring class for method call to '<>' declared in Foo was not matched with found receiver java.lang.Object. This should not have happened!
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.extractPlaceHolders(StaticTypeCheckingVisitor.java:3957)
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.resolvePlaceHoldersFromDeclaration(StaticTypeCheckingVisitor.java:3900)
      

      Only happens if the target property contains generic information.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: