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

Type inference doesn't work with a Java class and a static property

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

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

    Description

      Example:

      @Grab(group='org.grails', module='grails-bootstrap', version='2.0.4')
      import grails.util.Metadata
      import groovy.transform.CompileStatic
      
      @CompileStatic
      def foo() {
         Metadata m = Metadata.current
      }
      

      Results in:

      [Static type checking] - Cannot assign value of type java.lang.Object to variable of type grails.util.Metadata
       at line: 7, column: 4
      

      The class Metadata has a Java static method that looks roughly like:

      public static Metadata getCurrent() { ... }
      

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment