groovy
  1. groovy
  2. GROOVY-2323

Parser fails to recognize function calls properly

    Details

    • Type: Wish Wish
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 4.0
    • Component/s: parser
    • Labels:
      None
    • Number of attachments :
      0

      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 }
          }
      }
      

        Issue Links

          Activity

          Hide
          Paul King added a comment -

          Add code tags

          Show
          Paul King added a comment - Add code tags
          Hide
          blackdrag blackdrag added a comment -

          assuming there is a class GENERATE_SOMETHING and GenerateSomething, there is no way of seeing if it is intended as method call or as declaration

          Show
          blackdrag blackdrag added a comment - assuming there is a class GENERATE_SOMETHING and GenerateSomething, there is no way of seeing if it is intended as method call or as declaration

            People

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

              Dates

              • Created:
                Updated: