Thu, 10 Oct 2013 14:58:04 +0200
8001931: The new build system whitespace cleanup
Reviewed-by: tbell, simonis, erikj
mcimadamore@1609 | 1 | /* |
mcimadamore@1609 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
mcimadamore@1609 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
mcimadamore@1609 | 4 | * |
mcimadamore@1609 | 5 | * This code is free software; you can redistribute it and/or modify it |
mcimadamore@1609 | 6 | * under the terms of the GNU General Public License version 2 only, as |
mcimadamore@1609 | 7 | * published by the Free Software Foundation. |
mcimadamore@1609 | 8 | * |
mcimadamore@1609 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
mcimadamore@1609 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
mcimadamore@1609 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
mcimadamore@1609 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
mcimadamore@1609 | 13 | * accompanied this code). |
mcimadamore@1609 | 14 | * |
mcimadamore@1609 | 15 | * You should have received a copy of the GNU General Public License version |
mcimadamore@1609 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
mcimadamore@1609 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
mcimadamore@1609 | 18 | * |
mcimadamore@1609 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
mcimadamore@1609 | 20 | * or visit www.oracle.com if you need additional information or have any |
mcimadamore@1609 | 21 | * questions. |
mcimadamore@1609 | 22 | */ |
mcimadamore@1609 | 23 | |
mcimadamore@1609 | 24 | /* |
mcimadamore@1609 | 25 | * @test |
mcimadamore@1609 | 26 | * @bug 8008813 |
mcimadamore@1609 | 27 | * @summary Structural most specific fails when method reference is passed to overloaded method |
vromero@2000 | 28 | * @compile/fail/ref=MostSpecific08.out -XDrawDiagnostics MostSpecific08.java |
mcimadamore@1609 | 29 | */ |
mcimadamore@1609 | 30 | class MostSpecific08 { |
mcimadamore@1609 | 31 | |
mcimadamore@1609 | 32 | static class C { |
mcimadamore@1609 | 33 | int getInt() { return -1; } |
mcimadamore@1609 | 34 | Integer getInteger() { return -1; } |
mcimadamore@1609 | 35 | } |
mcimadamore@1609 | 36 | |
mcimadamore@1609 | 37 | interface IntResult { } |
mcimadamore@1609 | 38 | interface ReferenceResult<X> { } |
mcimadamore@1609 | 39 | |
mcimadamore@1609 | 40 | interface PrimitiveFunction { |
mcimadamore@1609 | 41 | int f(C c); |
mcimadamore@1609 | 42 | } |
mcimadamore@1609 | 43 | |
mcimadamore@1609 | 44 | interface ReferenceFunction<X> { |
mcimadamore@1609 | 45 | X f(C c); |
mcimadamore@1609 | 46 | } |
mcimadamore@1609 | 47 | |
mcimadamore@1609 | 48 | interface Tester { |
mcimadamore@1609 | 49 | IntResult apply(PrimitiveFunction p); |
mcimadamore@1609 | 50 | <Z> ReferenceResult<Z> apply(ReferenceFunction<Z> p); |
mcimadamore@1609 | 51 | } |
mcimadamore@1609 | 52 | |
mcimadamore@1609 | 53 | void testMref(Tester t) { |
vromero@2000 | 54 | IntResult pr = t.apply(C::getInt); //ok - unoverloaded mref |
vromero@2000 | 55 | ReferenceResult<Integer> rr = t.apply(C::getInteger); //ok - unoverloaded mref |
mcimadamore@1609 | 56 | } |
mcimadamore@1609 | 57 | |
mcimadamore@1609 | 58 | void testLambda(Tester t) { |
vromero@2000 | 59 | IntResult pr1 = t.apply(c->c.getInt()); //ambiguous - implicit |
vromero@2000 | 60 | IntResult pr2 = t.apply((C c)->c.getInt()); //ok |
vromero@2000 | 61 | ReferenceResult<Integer> rr1 = t.apply(c->c.getInteger()); //ambiguous - implicit |
vromero@2000 | 62 | ReferenceResult<Integer> rr2 = t.apply((C c)->c.getInteger()); //ok |
mcimadamore@1609 | 63 | } |
mcimadamore@1609 | 64 | } |