test/tools/javac/lambda/MostSpecific08.java

Tue, 12 Mar 2013 16:02:43 +0000

author
mcimadamore
date
Tue, 12 Mar 2013 16:02:43 +0000
changeset 1628
5ddecb91d843
parent 1609
332f23993353
child 2000
4a6acc42c3a1
permissions
-rw-r--r--

8009545: Graph inference: dependencies between inference variables should be set during incorporation
Summary: Move all transitivity checks into the incorporation round
Reviewed-by: jjg

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
mcimadamore@1609 28 * @compile 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) {
mcimadamore@1609 54 IntResult pr = t.apply(C::getInt);
mcimadamore@1609 55 ReferenceResult<Integer> rr = t.apply(C::getInteger);
mcimadamore@1609 56 }
mcimadamore@1609 57
mcimadamore@1609 58 void testLambda(Tester t) {
mcimadamore@1609 59 IntResult pr = t.apply(c->c.getInt());
mcimadamore@1609 60 ReferenceResult<Integer> rr = t.apply(c->c.getInteger());
mcimadamore@1609 61 }
mcimadamore@1609 62 }

mercurial