Skip to content

Instantly share code, notes, and snippets.

@kmizu
Created September 14, 2016 15:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmizu/25b6130df3ad943e15c0ed5b4865c605 to your computer and use it in GitHub Desktop.
Save kmizu/25b6130df3ad943e15c0ed5b4865c605 to your computer and use it in GitHub Desktop.
public class Unsound {
static class Bound<A, B extends A> {}
static class Bind<A> {
<B extends A> A bad(Bound<A,B> bound, B b) {return b;}
}
public static <T,U> U coerce(T t) {
Bound<U,? super T> bound = null;
Bind<U> bind = new Bind<U>();
return bind.bad(bound, t);
}
public static void main(String[] args) {
String s = Unsound.coerce(new Object());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment