Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.5.9, 3.0.0-rc-3
-
None
Description
The following code
class Foo { int bar } trait TestTrait { def foo = new Foo().tap{ bar = 1 } } class SomeClass implements TestTrait { } new SomeClass()
fails with the following error:
Caught: groovy.lang.MissingPropertyException: No such property: bar for class: SomeClass Possible solutions: foo groovy.lang.MissingPropertyException: No such property: bar for class: SomeClass Possible solutions: foo at TestTrait$Trait$Helper$__init__closure1.doCall(scratch.groovy:8) at TestTrait$Trait$Helper.$init$(scratch.groovy:7) at SomeClass.<init>(scratch.groovy) at scratch.run(scratch.groovy:16)
if using the following code in the tap makes it work correctly:
trait TestTrait { def foo = new Foo().tap{ it.bar = 1 } }
Also when used in a class directly, it works also correctly:
class SomeClass { def foo = new Foo().tap{ bar = 1 } }