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

Compile static: Groovyc reports error after instanceof check

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.6
    • 2.1.0
    • Static compilation
    • None

    Description

      @CompileStatic
      class AnnotationCollectorChecker {
        boolean checkApplicability(PsiElement annotation) {
          final PsiElement parent = annotation.parent
          if (parent instanceof GrModifierList) {
            final collector = parent.rawAnnotations //compile error 'Access to com.intellij.psi.PsiElement#rawAnnotations'
            if (collector != null) {
              return true
            }
          }
      
          return false
        }
      }
      

      I created a class in IntelliJ IDEA project and Groovy fails to compile it though GrModifierList has a 'getRawAnnotations()' method.

      If I replace 'rawAnnotations' with 'getRawAnnotations()' Groovyc doesn't report errors.

      PsiElement source https://github.com/JetBrains/intellij-community/blob/master/platform/core-api/src/com/intellij/psi/PsiElement.java

      GrModifierList source https://github.com/JetBrains/intellij-community/blob/master/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/auxiliary/modifiers/GrModifierList.java

      I'm sorry but I didn't manage to reproduce the issue on simple project

      Attachments

        Activity

          People

            asteingress Andre Steingress
            mxm-groovy Maxim Medvedev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: