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

Type not captured correctly (regression in 2.5.18)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.18
    • 2.5.19
    • Static Type Checker
    • None

    Description

      Consider this:

      package test2
      import groovy.transform.CompileStatic
      
      @CompileStatic
      class OptionalTest {
          
          void foo() {
              Optional.of(bar()).orElse(Collections.emptyMap());
          }
          
          Map bar() {
              new HashMap()
          }
      } 

      This compiles fine in 2.5.17, 2.5.16, etc., but fails with 2.5.18:

      [Static type checking] - Cannot call java.util.Optional <java.util.Map>#orElse(java.util.Map) with arguments [java.lang.Object]  
       @ line 9, column 3.
      
                      Optional.of(bar()).orElse(Collections.emptyMap());
      
           ^
      
      
      
      1 error
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              mauromol Mauro Molinari
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: