Created
January 25, 2017 11:46
-
-
Save opqdonut/5082314d0bd077fb1b2175e1f6cdb3f2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Unsound { | |
| static class Constrain<A, B extends A> {} | |
| static class Bind<A> { | |
| <B extends A> A upcast(Constrain<A,B> constrain, B b) { | |
| return b; | |
| } | |
| } | |
| static <T,U> U coerce(T t) { | |
| Constrain<U, ? super T> constrain = null; | |
| Bind<U> bind = new Bind<U>(); | |
| return bind.upcast(constrain, t); | |
| } | |
| public static void main(String[] args) { | |
| String zero = Unsound.<Integer,String>coerce(0); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment