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

Trait properties with 'with'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.7
    • 4.0.0-alpha-1, 3.0.6
    • None
    • None

    Description

      @CompileStatic
      interface I {
        String getFoo()
      }
      
      @CompileStatic
      trait T {
      
        abstract I getProp()
      
        def usage() {
          prop.with {
            foo.toUpperCase() 
      // Groovyc: [Static type checking] - Cannot find matching method java.lang.Object#toUpperCase(). Please check if the declared type is right and if the method exists.
      // works when changed to getFoo().toUpperCase() 
          }
        }
      }
      
      @CompileStatic
      class Main implements T {
      
        I prop = { "hello" } as I
      
        static void main(String[] args) {
          println new Main().usage()
        }
      }
      

      Attachments

        Activity

          People

            emilles Eric Milles
            daniilo Daniil Ovchinnikov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: