test/tools/javac/lambda/8016177/T8016177f.java

Thu, 31 Aug 2017 15:17:03 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:17:03 +0800
changeset 2525
2eb010b6cb22
parent 0
959103a6100f
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test
    26  * @bug 8016081 8016178
    27  * @summary structural most specific and stuckness
    28  * @compile T8016177f.java
    29  */
    30 import java.util.*;
    32 class T8016177f {
    34     interface Function<S, T> {
    35        T apply(S s);
    36     }
    38     interface IntFunction<T> {
    39        T apply(int s);
    40     }
    43     interface BiConsumer<X,Y> {
    44        void m(X x, Y y);
    45     }
    47     interface Consumer<X> {
    48        void m(X x);
    49     }
    51     interface Supplier<X> {
    52        X make();
    53     }
    55     interface TestData<T, S extends BaseStream<T, S>> {
    56        interface OfRef<T> extends TestData<T, Stream<T>> { }
    57        interface OfDouble extends TestData<Double, DoubleStream> { }
    58     }
    60     interface BaseStream<T, S extends BaseStream<T, S>> { }
    62     interface Stream<T> extends BaseStream<T, Stream<T>> {
    63        <M> Stream<M> map(Function<T, M> s);
    64        <R> R collect(Supplier<R> resultFactory, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner);
    65        <Z> Z[] toArray(IntFunction<Z[]> s);
    66     }
    68     interface DoubleStream extends BaseStream<Double, DoubleStream> {
    69        DoubleStream filter(DoublePredicate dp);
    70        double[] toArray();
    71     }
    73     interface DoublePredicate {
    74        boolean p(double d);
    75     }
    77     <T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
    78            R exerciseTerminalOps(TestData<T, S_IN> data,
    79                                  Function<S_IN, S_OUT> streamF,
    80                                  Function<S_OUT, R> terminalF) { return null; }
    82     <O> TestData.OfRef<O> ofCollection(Collection<O> collection) { return null; }
    84     void test1(TestData.OfDouble data, DoublePredicate dp) {
    85         exerciseTerminalOps(data, s -> s.filter(dp), s -> s.toArray());
    86     }
    88     void test2(Function<Double, Integer> fdi, TestData.OfRef<Double> td, Stream<Integer> si) {
    89         exerciseTerminalOps(
    90                         ofCollection((List<Double>)null),
    91                         s -> s.map(fdi),
    92                         s -> s.toArray(Integer[]::new));
    93     }
    94 }

mercurial