Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.0-rc-2
-
None
-
None
-
Groovy Version: 2.3.0-rc-2 JVM: 1.8.0_05 Vendor: Oracle Corporation OS: Mac OS X
Description
class Foo1 { static call_directly() { foo() } static call_inClosure() { {-> foo() }.call() } static foo() { "FOO" } } class Foo2 { // 'private' and 'static' don't affect this issue. class Bar { static call_directly() { foo() } static call_inClosure() { {-> foo() }.call() } static call_inClosure_others() { {-> Foo1.foo() }.call() } static foo() { "FOO" } } } assert Foo1.call_directly() == 'FOO' assert Foo1.call_inClosure() == 'FOO' // -- [1] assert Foo2.Bar.call_directly() == 'FOO' GroovyAssert.shouldFail(ClassCastException) { // WHY?? -- [2] Foo2.Bar.call_inClosure() } assert Foo2.Bar.call_inClosure_others() == 'FOO' // -- [3]
[1] It's no problem in a root class.
[2] ClassCastException occurs.
[3] It's no problem to call a other class's static method.