Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.6-beta-2
-
Fix Version/s: 1.6-rc-1, 1.7-beta-1
-
Component/s: bytecode
-
Labels:None
-
Number of attachments :
Description
The following code
foo = new Foo() if(foo.hello()()) { println "do" println "do" println "do" println "do" } class Foo { boolean hello() {true} }
Produces the error
groovy.lang.MissingMethodException: No signature of method: java.lang.Boolean.call() is applicable for argument types: () values: {} at Script1.run(Script1:7)
As you can see the line number says its line 7 (the closing bracket of the if) which is confusing as the actual problem is on line 3. I spent ages slowing ripping out more and more code inside a larger if trying to figure out what the problem was
Issue Links
- relates to
-
GROOVY-2983
wrong line number in 1.6 for getting an property
-
as far as I can see the reason for this is that in rev 10638 the method call path did go out of ScriptBytecodeAdapter into call site caching. At that point the usual exception unwraping we do in unwarp of that class went into a direct call in the class itselft. As a result the unwrap call is nowat the very end of the method. Now as a performance optimization we have stackless exception in case the method is not found. these Exception are catched and converted in unwrap. In 1.5.x the unwrap happens before we go back in the calling bytecode. In 1.6 it is part of the calling bytecode. As a result the line number information is now wrong.