Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
This issue is raised based on dev mailing list discussion here: http://markmail.org/message/ksngkezqgqazpz5q
Here are the code snippets that demonstrate the issue with constructor call generation when anonymous inner classes and closure are used together.
1)
interface X{} final double delta = 0.1 (0 ..< 1).collect { n -> new X () { Double foo () { delta } } }
fails with
Caught: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: TryGroovy$1(TryGroovy, java.lang.Double)
2) Seems like there is some mix-up with the variables used from the enclosing context. In this snippet, I use 2 variables from enclosing context, and both become part of constructor call that fails.
interface X{} final double delta1 = 0.1 final double delta2 = 0.1 (0 ..< 1).collect { n -> new X () { Double foo () { delta1 + delta2 } } }
fails with:
Caught: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: TryGroovy$1(TryGroovy, java.lang.Double, java.lang.Double)