Skip to content

Instantly share code, notes, and snippets.

@rvprasad
Last active October 21, 2017 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvprasad/be9849dea30a16fb31f5e5e2e3d5fd7f to your computer and use it in GitHub Desktop.
Save rvprasad/be9849dea30a16fb31f5e5e2e3d5fd7f to your computer and use it in GitHub Desktop.
Illustrates when Java's method resolution is not honored in Groovy.
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