Last active
October 21, 2017 02:06
-
-
Save rvprasad/be9849dea30a16fb31f5e5e2e3d5fd7f to your computer and use it in GitHub Desktop.
Illustrates when Java's method resolution is not honored in Groovy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
protected foo() { | |
this.bar("Site foo1") | |
def x = { | |
println("This: ${this.class}") | |
this.bar("Site foo2") | |
} | |
x() | |
} | |
private bar(i) { | |
println("Bar called from $i") | |
} | |
protected cow() { | |
this.bar("Site cow") | |
} | |
} | |
class B extends A { } | |
new A().foo() | |
new B().cow() | |
new B().foo() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment