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

Trait properties with 'with'

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.7
    • Fix Version/s: 4.0.0-alpha-1, 3.0.6
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: