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

Static Type Checker: Type not inferred from maps with generics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-rc-3
    • 2.0-rc-4
    • Static Type Checker
    • None

    Description

      Following code:

      @GrabResolver('http://repo.grails.org/grails/core')
      @Grab(group='org.grails', module='grails-bootstrap', version='2.0.4')
      import org.codehaus.groovy.grails.plugins.*
      import groovy.transform.CompileStatic
      
      
      
      @CompileStatic
      GrailsPluginInfo getPluginName(String pluginName) {
          Map<String, GrailsPluginInfo> pluginInfosMap = new HashMap<String, GrailsPluginInfo>()
          return pluginInfosMap[pluginName]
      }
      

      Produces:

      
      [Static type checking] - Cannot return value of type java.lang.Object on method returning type org.codehaus.groovy.grails.plugins.GrailsPluginInfo -> org.codehaus.groovy.grails.plugins.GrailsPluginInfo
       at line: 11, column: 12
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            graemerocher Graeme Rocher
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: