test/langtools/tools/javac/lambda/T8213703/InvalidReceiverTypeTest.java
author vromero
Wed, 05 Dec 2018 09:34:01 -0500
changeset 52849 eef755718cb2
permissions -rw-r--r--
8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52849
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
     1
/*
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
     4
 *
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
     7
 * published by the Free Software Foundation.
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
     8
 *
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    13
 * accompanied this code).
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    14
 *
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    18
 *
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    21
 * questions.
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    22
 */
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    23
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    24
/*
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    25
 * @test
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    26
 * @bug 8213703
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    27
 * @summary LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    28
 */
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    29
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    30
import java.util.Arrays;
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    31
import java.util.List;
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    32
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    33
public class InvalidReceiverTypeTest {
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    34
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    35
    static abstract class A {}
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    36
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    37
    interface B {
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    38
        boolean g();
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    39
    }
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    40
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    41
    static class C extends A implements B {
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    42
        public boolean g() {
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    43
            return true;
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    44
        }
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    45
    }
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    46
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    47
    static class D<R extends A & B> {
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    48
        public long f(List<? extends R> xs) {
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    49
            return xs.stream().filter(B::g).count();
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    50
        }
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    51
    }
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    52
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    53
    public static void main(String[] args) {
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    54
        long count = new D<C>().f(Arrays.asList(new C()));
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    55
        System.err.println(count);
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    56
    }
eef755718cb2 8213703: LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
vromero
parents:
diff changeset
    57
}