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

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.2, 2.3.0-rc-1
    • 2.3.0-rc-2, 2.2.3
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: