Details
-
Sub-task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5
-
None
-
None
-
Groovy Version: 1.5.0 JVM: 1.6.0_03-b05
Description
This script works:
class Super { def test2() { println "test2" } } Super.metaClass.test3 = { println "test3" } class Sub extends Super { def test4() { println "test4"; super.test3() } } Sub.metaClass // Does not work without this line new Super().test2() new Super().test3() new Sub().test2() new Sub().test3() new Sub().test4()
It outputs:
test2 test3 test2 test3 test4 test3
But when I remove the commented line (Sub.metaClass), it does not work anymore. You get the following stacktrace:
test2
test3
test2
Caught: groovy.lang.MissingMethodException: No signature of method: Sub.test3() is applicable for argument types: () values: {}
at Super.invokeMethod(test1.groovy)
at test1.run(test1.groovy:18)
at test1.main(test1.groovy)
I think that calling Sub.metaClass should not have such a sideeffect.
The script should work with or without it.
Attachments
Issue Links
- depends upon
-
GROOVY-2503 MOP 2.0 design inflluencing issues
- Open