summaryrefslogtreecommitdiff
path: root/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/methodRef/RefOnArrayDeclaration.java
blob: f11a6dedddc93b270553edbbfcd190b14aac2bb1 (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
54
55
56
57
58
59
60
class OnArrayTest {

    interface Cln {
       Object m(int[] i);
    }

    interface IA {
        void m(int i);
    }

    interface I {
        void m(int[] i);
    }

    interface Len<T> {
        int len(T[] ta);
    }


    interface ToStr<T> {
        String _(T[] ta);
    }

    interface ArrayReturnType<T> {
        T make(int size);
    }

    static class Foo<X> { }
    interface ObjectArrayReturnType {
        Object make(int size);
    }

    public static void main(String[] args) {
        Cln s =  int[]::clone;
        IA a =  int[]::new;
        <error descr="Incompatible types. Found: '<method reference>', required: 'OnArrayTest.I'">I i = int[]::new;</error>
        Len<String> strLen = String[]::<error descr="Cannot resolve method 'length'">length</error>;
        ToStr<Integer> toStr = Integer[]::toString;

        ArrayReturnType<String[]> a1 = String[]::new;
        ArrayReturnType<String[][]> a2 = String[][]::new;
        <error descr="Incompatible types. Found: '<method reference>', required: 'OnArrayTest.ArrayReturnType<java.lang.String[]>'">ArrayReturnType<String[]> a3 = int[]::new;</error>
        
        ObjectArrayReturnType a4 = Foo<?>[]::new;
        ObjectArrayReturnType a5 = <error descr="Generic array creation">Foo<? extends String>[]</error>::new;
    }
}


class IDEA106973 {
  interface Function<T, R> {
    R apply(T t);
  }
  
  {
    Function<Integer, String[]> a  = String[] :: new;
    <error descr="Incompatible types. Found: '<method reference>', required: 'IDEA106973.Function<java.lang.String,java.lang.String[]>'">Function<String, String[]> a1  = String[] :: new;</error>
    Function<Short, String[]> a2  = String[] :: new;
  }
}