Details
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
-
Activity
blackdrag blackdrag
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Link | This issue relates to GROOVY-2324 [ GROOVY-2324 ] |
Paul King
made changes -
| 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 } } } |
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: {code} 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 } } } {code} |
blackdrag blackdrag
made changes -
| Assignee | blackdrag blackdrag [ blackdrag ] | |
| Fix Version/s | 4.0 [ 18928 ] |