aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources/com/puppycrawl/tools/checkstyle/grammars/java8/InputMethodReferences7.java
blob: 5998d2500043aedb28a02301b4e3c5451d431abb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//Compilable with Java8
package com.puppycrawl.tools.checkstyle.grammars.java8;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;

public class InputMethodReferences7 {
    interface LambdaInt {
        <S, T> void m(S p1, T p2);
    }

    interface MyFunctionalInterface {
        void invokeMethodReference();
    }

    static class LambdaImpl implements LambdaInt {
        <S, T> LambdaImpl(S p1, T p2) {
        }

        public <S, T> void m(S p1, T p2) {
        }
    }

    public void m() {
    }

    public void main(String[] args) {
        MyFunctionalInterface fi = new InputMethodReferences7()::<Integer, String, Long> m;
        LambdaInt li = LambdaImpl::<@TA Object, @TB Object> new;
        Supplier s = Bar::<String> m;
        li = li::<@TA Object, @TB Object> m;
        s = Bar::<List<String>> m;
        s = Bar::<List<List<?>>> m;
    }
}

class Bar<T> {
    static Object m() {
        return null;
    }
}

@Target({ ElementType.TYPE_USE, ElementType.TYPE_PARAMETER })
@interface TA {
}

@Target({ ElementType.TYPE_USE, ElementType.TYPE_PARAMETER })
@interface TB {
}