langtools/test/tools/javac/lambda/MostSpecific22.java
author lana
Tue, 25 Apr 2017 07:38:50 +0000
changeset 44909 b53c770dc04f
parent 43033 c37b643739a7
permissions -rw-r--r--
Added tag jdk-10+1 for changeset 3a409afd3f86
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34995
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
     1
/*
43033
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
34995
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
     4
 *
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
     8
 *
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    13
 * accompanied this code).
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    14
 *
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    18
 *
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    21
 * questions.
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    22
 */
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    23
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    24
/*
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    25
 * @test
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    26
 * @bug 8143852
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    27
 * @summary Most specific inference constraints derived from both functional interface method parameters and tparam bounds
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    28
 */
43033
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
    29
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
    30
public class MostSpecific22 {
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
    31
    public static void main(String[] args) {
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
    32
        new MostSpecific22().test();
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
    33
    }
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
    34
34995
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    35
    interface F1<T> { <X extends T> Object apply(T arg); }
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    36
    interface F2 { <Y extends Number> String apply(Number arg); }
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    37
43033
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
    38
    static <T> T m1(F1<T> f) {
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
    39
        throw new AssertionError("Less-specific method invocation.");
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
    40
    }
34995
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    41
    static Object m1(F2 f) { return null; }
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    42
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    43
    static String foo(Object in) { return "a"; }
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    44
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    45
    void test() {
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    46
        m1(MostSpecific22::foo);
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    47
    }
e4e19f521ee7 8143852: Implement type variable renaming for functional interface most specific test
dlsmith
parents:
diff changeset
    48
43033
c37b643739a7 8148100: Convert lambda most specific positive tests to check runtime behavior
vromero
parents: 34995
diff changeset
    49
}