Last active
August 13, 2020 18:35
-
-
Save nothub/cadd93c4b40a90955e6fe306e9c05730 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
package not.hub.test; | |
class UnsoundTypeBreakage<T, U> { | |
final Constrain<? super T> constrain; | |
final U u; | |
UnsoundTypeBreakage(T t) { | |
u = coerce(t); | |
constrain = getConstrain(); | |
} | |
public static void main(String[] args) { | |
String zero = new UnsoundTypeBreakage<Integer, String>(0).u; | |
} | |
<B extends U> | |
U upcast(Constrain<B> constrain, B b) { | |
return b; | |
} | |
U coerce(T t) { | |
return upcast(constrain, t); | |
} | |
Constrain<? super T> getConstrain() { | |
return constrain; | |
} | |
class Constrain<B extends U> { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment