Details
-
Type:
Sub-task
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.7.5
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
The following code...
InnerClassGString.groovy:
class Outer {
def foo() {
def r = new Runnable() {
public void run() {
println "value of x is $x" // ${getX()} works, also $x with a field x
}
}
r.run()
}
def getX() { 10 }
}
new Outer().foo()
...produces (when run via groovy command):
Caught: groovy.lang.MissingFieldException: No such field: x for class: Outer at Outer.this$dist$get$2(InnerClassGString.groovy) at Outer$1.propertyMissing(InnerClassGString.groovy) at Outer$1.run(InnerClassGString.groovy:5) at Outer.foo(InnerClassGString.groovy:8) at InnerClassGString.run(InnerClassGString.groovy:14)
Doesn't have anything to do with GString, because the following version also fails with the same error
class Outer { def foo() { def r = new Runnable() { public void run() { def y = x println y } } r.run() } def getX() { 10 } } new Outer().foo()