-
-
Save anthony-cros/8f7a34ab9849b0d1b104b7d414274061 to your computer and use it in GitHub Desktop.
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
// $ cat Bar.java: | |
interface Bar<F> { | |
F f (); | |
default F bar() { return f(); } | |
} | |
// ================================================== | |
// $ cat Foo.java: | |
class Foo implements Bar<Foo> { | |
@Override public Foo f() { return this; } | |
} | |
// ================================================== | |
// $ cat Baz.java: | |
class Baz { | |
public static void main(String args[]) { | |
Foo foo = new Foo().bar(); // works without cast | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment