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

Smart type inference doesn't work on explicit closure params

    XMLWordPrintableJSON

Details

    Description

      Should be compiled well:

      @CompileStatic
      class TestType {
          static def bar(Object b) {
              b.with { obj ->
                  assert obj instanceof String
                  obj.toUpperCase() // error: Cannot find matching method java.lang.Object#toUpperCase(). 
              }
          }
      }
      

      Funny moment - on implicit 'it' parameter works fine:

      @CompileStatic
      class TestType {
          static def bar(Object b) {
              b.with {
                  assert it instanceof String
                  it.toUpperCase()
              }
          }
      }
      

      Attachments

        Issue Links

          Activity

            People

              daniel_sun Daniel Sun
              Alexey Afanasiev Alexey Afanasiev
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: