MethodReference44.java revision 1999:4a6acc42c3a1
1100280Sgordon/* 225184Sjkh * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 3100280Sgordon * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 466830Sobrien * 550472Speter * This code is free software; you can redistribute it and/or modify it 666830Sobrien * under the terms of the GNU General Public License version 2 only, as 725184Sjkh * published by the Free Software Foundation. 8117019Smtm * 9197527Shrs * This code is distributed in the hope that it will be useful, but WITHOUT 10136224Smtm * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1125184Sjkh * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12100280Sgordon * version 2 for more details (a copy is included in the LICENSE file that 13179079Sbrooks * accompanied this code). 1425184Sjkh * 15117019Smtm * You should have received a copy of the GNU General Public License version 16117019Smtm * 2 along with this work; if not, write to the Free Software Foundation, 17117019Smtm * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18117019Smtm * 19117019Smtm * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20117019Smtm * or visit www.oracle.com if you need additional information or have any 2185831Sdes * questions. 22117019Smtm */ 23100280Sgordon 24197139Shrs/* 25197139Shrs * @test 26117019Smtm * @bug 8003280 27117019Smtm * @summary Add lambda tests 28117019Smtm * check that generic method reference is inferred when type parameters are omitted 29117019Smtm * @compile/fail/ref=MethodReference44.out -XDrawDiagnostics MethodReference44.java 30197699Shrs */ 31197699Shrspublic class MethodReference44 { 32197139Shrs 33197699Shrs static class SuperFoo<X> { } 34197699Shrs 35197699Shrs static class Foo<X extends Number> extends SuperFoo<X> { } 36197699Shrs 37197699Shrs interface SAM1 { 38197699Shrs SuperFoo<String> m(); 39197699Shrs } 40197699Shrs 41197699Shrs interface SAM2 { 42197699Shrs SuperFoo<Integer> m(); 43197699Shrs } 44197699Shrs 45197699Shrs interface SAM3 { 46197699Shrs SuperFoo<Object> m(); 47197699Shrs } 48197139Shrs 49197139Shrs static <X extends Number> Foo<X> m() { return null; } 50197139Shrs 51117019Smtm static void g1(SAM1 s) { } 52117019Smtm 53117019Smtm static void g2(SAM2 s) { } 54117019Smtm 55197139Shrs static void g3(SAM3 s) { } 56197139Shrs 57197139Shrs static void g4(SAM1 s) { } 58197139Shrs static void g4(SAM2 s) { } 59197699Shrs static void g4(SAM3 s) { } 60197699Shrs 61197139Shrs public static void main(String[] args) { 62197699Shrs g1(MethodReference44::m); 63197699Shrs g2(MethodReference44::m); 64197139Shrs g3(MethodReference44::m); 65197139Shrs g4(MethodReference44::m); 66197139Shrs } 67197139Shrs} 68197139Shrs