Last active
August 29, 2015 13:56
-
-
Save spullara/9175196 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
package spullara; | |
public class ExceptionInferenceBug { | |
interface Function<T, V> extends PartialFunction<T, V> { | |
V apply(T paramT); | |
} | |
interface PartialFunction<T, V> { | |
V apply(T paramT) throws Exception; | |
} | |
interface O {} | |
static <T, V> void run(Function<? super O, V> function) {} | |
static <T, V> void run(PartialFunction<? super O, V> function) {} | |
static <T, V> void run2(Function<O, V> function) {} | |
static <T, V> void run2(PartialFunction<O, V> function) {} | |
public static void main(String[] args) { | |
run(t -> t.toString()); // causes an assertion error | |
run((O t) -> t.toString()); // ambiguous | |
run((O t) -> { throw new Exception(); }); | |
run2(t -> t.toString()); // works | |
run2((O t) -> { throw new Exception(); }); // ambiguous | |
run2((PartialFunction<O, Void>) (O t) -> { throw new Exception(); }); // works | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment