2012-10-04 12:04:53 +00:00
|
|
|
/*
|
2013-09-02 21:38:36 +00:00
|
|
|
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
2012-10-04 12:04:53 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*/
|
|
|
|
|
2012-11-17 19:01:03 +00:00
|
|
|
/*
|
|
|
|
* @test
|
|
|
|
* @bug 8003280
|
|
|
|
* @summary Add lambda tests
|
|
|
|
* check that generic method reference is inferred when type parameters are omitted
|
2013-09-02 21:38:36 +00:00
|
|
|
* @compile/fail/ref=MethodReference46.out -XDrawDiagnostics MethodReference46.java
|
2012-11-17 19:01:03 +00:00
|
|
|
*/
|
|
|
|
public class MethodReference46 {
|
2012-10-04 12:04:53 +00:00
|
|
|
|
2012-11-17 19:01:03 +00:00
|
|
|
interface SAM1 {
|
|
|
|
void m(String s);
|
|
|
|
}
|
|
|
|
|
|
|
|
interface SAM2 {
|
|
|
|
void m(Integer s);
|
|
|
|
}
|
|
|
|
|
|
|
|
interface SAM3 {
|
|
|
|
void m(Object o);
|
|
|
|
}
|
|
|
|
|
|
|
|
static class Foo<X extends Number> {
|
|
|
|
Foo(X x) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
static <X extends Number> void m(X fx) { }
|
|
|
|
|
2013-09-02 21:38:36 +00:00
|
|
|
static void g1(SAM1 s) { }
|
|
|
|
|
|
|
|
static void g2(SAM2 s) { }
|
|
|
|
|
|
|
|
static void g3(SAM3 s) { }
|
|
|
|
|
|
|
|
static void g4(SAM1 s) { }
|
|
|
|
static void g4(SAM2 s) { }
|
|
|
|
static void g4(SAM3 s) { }
|
2012-10-04 12:04:53 +00:00
|
|
|
|
2012-11-17 19:01:03 +00:00
|
|
|
public static void main(String[] args) {
|
2013-09-02 21:38:36 +00:00
|
|
|
g1(MethodReference46::m);
|
|
|
|
g2(MethodReference46::m);
|
|
|
|
g3(MethodReference46::m);
|
|
|
|
g4(MethodReference46::m);
|
2012-11-17 19:01:03 +00:00
|
|
|
}
|
2012-10-04 12:04:53 +00:00
|
|
|
}
|