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

CompileStatic fails to infer correct type when using elvis operator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.9
    • 2.4.13
    • Static Type Checker
    • None

    Description

      see the following example:

      import groovy.transform.CompileStatic
      
      
      @CompileStatic
      def foo() {
          Map<String, String> strongMap
          Map<String, String> elvisMap = strongMap ?: [:] // won't compile
          Map<String, String> initStrongMap = [:] // compiles ok
      }
      
      

      Attachments

        Activity

          People

            jwagenleitner John Wagenleitner
            pootow Richard Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: