Details
-
Type:
Wish
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
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 }
}
}
Issue Links
- relates to
-
GROOVY-2324
grammar forces usage of lowercase names for commands
-
Add code tags