Skip to content

Instantly share code, notes, and snippets.

@techtangents
Created January 28, 2016 10:14
Show Gist options
  • Save techtangents/66f5d4578d9b9e3a0475 to your computer and use it in GitHub Desktop.
Save techtangents/66f5d4578d9b9e3a0475 to your computer and use it in GitHub Desktop.
import java.util.function.Function;
public class Blah {
private Blah() {
}
static class A {
}
static class B extends A {
String foo(final String x) {
return x + "!";
}
}
static void f1(final Function<A, Void> k) {
k.apply(new A());
}
static void f2(final Function<B, Void> k) {
f1(k); // compile error - quite rightly: "b => Void" is not an "a => Void"
}
static {
f2(x -> {
System.out.println(x.foo("ABC"));
return null;
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment