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

Static compiler wrongly infers the return type of Class<T>.cast()

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

Details

    Description

      @CompileStatic
      class Test {
          public <T extends Runnable> T fails(Class<T> type, def x) {
              return type.cast(x) 
          }
          public <T extends Runnable> T passes(Class<T> type, def x) {
              return type.cast(x) as T
          }
      }
      

      Attachments

        Activity

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

          People

            blackdrag Jochen Theodorou
            ddimitrov Dimitar Dimitrov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment