Fri, 27 Sep 2013 10:24:56 +0100
8024497: crash returning this-referencing lambda from default method
Reviewed-by: jjg, rfield
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * @test /nodynamiccopyright/ |
aoqi@0 | 3 | * @bug 8016177 8016178 |
aoqi@0 | 4 | * @summary structural most specific and stuckness |
aoqi@0 | 5 | * @compile/fail/ref=T8016177b.out -XDrawDiagnostics T8016177b.java |
aoqi@0 | 6 | */ |
aoqi@0 | 7 | class T8016177b { |
aoqi@0 | 8 | interface ToIntFunction<X> { |
aoqi@0 | 9 | int m(X x); |
aoqi@0 | 10 | } |
aoqi@0 | 11 | |
aoqi@0 | 12 | interface Function<X, Y> { |
aoqi@0 | 13 | Y m(X x); |
aoqi@0 | 14 | } |
aoqi@0 | 15 | |
aoqi@0 | 16 | <U, V> Function<U, V> id(Function<U, V> arg) { return null; } |
aoqi@0 | 17 | |
aoqi@0 | 18 | <U, V> Function<U, V> id2(Function<U, V> arg) { return null; } |
aoqi@0 | 19 | <U> ToIntFunction<U> id2(ToIntFunction<U> arg) { return null; } |
aoqi@0 | 20 | |
aoqi@0 | 21 | |
aoqi@0 | 22 | <X,Y,Z> X f(Y arg, Function<Y, Z> f) { return null; } |
aoqi@0 | 23 | |
aoqi@0 | 24 | <X,Y,Z> X f2(Y arg, Function<Y, Z> f) { return null; } |
aoqi@0 | 25 | <X,Y> X f2(Y arg, ToIntFunction<Y> f) { return null; } |
aoqi@0 | 26 | |
aoqi@0 | 27 | <T> T g(T arg) { return null; } |
aoqi@0 | 28 | |
aoqi@0 | 29 | void test() { |
aoqi@0 | 30 | g(f("hi", id(x->1))); //ok |
aoqi@0 | 31 | g(f("hi", id2(x->1))); //ambiguous |
aoqi@0 | 32 | g(f2("hi", id(x->1))); //ok |
aoqi@0 | 33 | } |
aoqi@0 | 34 | } |