test/langtools/tools/javac/T8222035/MinContextOpTest.java
author vromero
Wed, 10 Apr 2019 17:15:53 -0400
changeset 54493 17b1c2c467ad
permissions -rw-r--r--
8222035: minimal inference context optimization is forcing resolution with incomplete constraints Reviewed-by: mcimadamore, cushon
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54493
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
     1
/*
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
     2
 * Copyright (c) 2019, Google LLC. All rights reserved.
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
     4
 *
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
     7
 * published by the Free Software Foundation.
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
     8
 *
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    13
 * accompanied this code).
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    14
 *
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    18
 *
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    21
 * questions.
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    22
 */
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    23
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    24
/*
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    25
 * @test
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    26
 * @bug 8222035
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    27
 * @summary minimal inference context optimization is forcing resolution with incomplete constraints
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    28
 * @compile/fail/ref=MinContextOpTest.out -XDrawDiagnostics MinContextOpTest.java
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    29
 */
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    30
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    31
import java.util.Map;
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    32
import java.util.function.Function;
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    33
import java.util.stream.Collector;
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    34
import java.util.stream.Stream;
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    35
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    36
public class MinContextOpTest {
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    37
    abstract class A {
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    38
        abstract static class T<K> {
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    39
            abstract String f();
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    40
        }
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    41
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    42
        abstract <E> Function<E, E> id();
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    43
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    44
        abstract static class ImmutableMap<K, V> implements Map<K, V> {}
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    45
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    46
        abstract <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    47
                Function<? super T, ? extends K> k, Function<? super T, ? extends V> v);
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    48
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    49
        ImmutableMap<String, T<?>> test(Stream<T> stream) {
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    50
            return stream.collect(toImmutableMap(T::f, id()));
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    51
        }
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    52
    }
17b1c2c467ad 8222035: minimal inference context optimization is forcing resolution with incomplete constraints
vromero
parents:
diff changeset
    53
}