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

Problem Parsing Expression With 1.8.0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.0
    • 1.8.4, 2.0-beta-1
    • Compiler
    • None

    Description

      The following works with 1.7.x but fails with 1.8.0

      Demo.groovy
      class Demo  {
         
         void doit() {
             execute new Runnable(){
                 void run() {
                     println 'hello'
                 }
             }
         }
         
         void execute(arg) {
             arg.run()
         }
         
         static void main(args) {
             new Demo().doit()
         }
      }
      

      The code fails with a MissingPropertyException:

      $ groovy Demo
      Caught: groovy.lang.MissingPropertyException: No such property: execute for class: Demo
              at Demo.doit(Demo.groovy:4)
              at Demo.main(Demo.groovy:16)
      

      If I put parens around the argument to the execute method, then it appears to work:

      Demo.groovy
      class Demo  {
         
         void doit() {
             execute(new Runnable(){
                 void run() {
                     println 'hello'
                 }
             })
         }
         
         void execute(arg) {
             arg.run()
         }
         
         static void main(args) {
             new Demo().doit()
         }
      }
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            brownj Jeff Brown
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: