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

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

    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

          People

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

            Dates

              Created:
              Updated:
              Resolved: