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

Parser fails to recognize function calls properly

    Details

    • Type: Wish
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 4.x
    • Component/s: parser
    • Labels:
      None

      Description

      Problem: Under certain circumstances (names starting with upper case letters) the parser fails to recognize certain function calls. I did not file it as bug, though, because after a closer look at the parser code, I found, that the reason for this behaviour is actually by design (and might be pretty hard to change; OTOH, this hack is truly gross enough to reward being filed as change-this! request. It makes you wonder, how many traps like that might be hidden somewhere else in the Groovy sources).

      Before having seen the parser code, I was completely surprised, when some of my code failed to compile because of this:

      class OldJavaLegacyCode {
      
          public def GenerateSomething(ob) {
              println("Old method ${ob}")
          }
      
          public def GENERATE_SOMETHING(ob) {
              println("Old method ${ob}")
          }
      
          public def generateSomething(ob) {
              println("Old method ${ob}")
          }
      }
      
      class ExtendsLegacyCode extends OldJavaLegacyCode {
      
          def wontCompile(sequence) {
              sequence.each { GENERATE_SOMETHING it }
          }
      
          def wontCompileNeither(sequence) {
              sequence.each { GenerateSomething it }
          }
      
          def willCompile(sequence) {
              sequence.each { generateSomething it }
          }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dirkesser Dirk Eßer
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: