aoqi@0: /* aoqi@0: * @test /nodynamiccopyright/ aoqi@0: * @bug 8003280 aoqi@0: * @summary Add lambda tests aoqi@0: * This is negative test for wrong parameter/return type in method references aoqi@0: * @compile/fail/ref=MethodRef_neg.out -XDrawDiagnostics MethodRef_neg.java aoqi@0: */ aoqi@0: aoqi@0: public class MethodRef_neg { aoqi@0: aoqi@0: static interface A {void m(Integer i);} aoqi@0: aoqi@0: static interface B {void m(String s);} aoqi@0: aoqi@0: static interface C {Integer m();} aoqi@0: aoqi@0: static interface D {String m();} aoqi@0: aoqi@0: aoqi@0: static void bar(int x) { } aoqi@0: aoqi@0: int foo() { aoqi@0: return 5; aoqi@0: } aoqi@0: aoqi@0: static void make() { } aoqi@0: aoqi@0: void method() { aoqi@0: A a = MethodRef_neg::bar; //boxing on parameter type is ok aoqi@0: B b = MethodRef_neg::bar; //wrong parameter type, required: String, actual: int aoqi@0: C c = this::foo; //boxing on return type is ok aoqi@0: D d = this::foo; //wrong return type, required: String, actual: int aoqi@0: a = MethodRef_neg::make; //missing parameter aoqi@0: c = MethodRef_neg::make; //missing return type aoqi@0: } aoqi@0: }