Bug 576174

Summary: Compile error: Variable length argument + Method reference
Product: [Eclipse Project] JDT Reporter: Shinji Kashihara <kashihara>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: loskutov
Version: 4.21Keywords: regression
Target Milestone: ---   
Hardware: PC   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=576152
Whiteboard:
Attachments:
Description Flags
Compile error: Variable length argument + Method reference none

Description Shinji Kashihara CLA 2021-09-21 22:07:50 EDT
Created attachment 287184 [details]
Compile error: Variable length argument + Method reference

Eclipse IDE for Enterprise Java and Web Developers
Version: 2021-09 4.21.0

Passing a method reference to a method with variable length arguments in a function interface will cause a compilation error.
This happens regardless of the Java version of the project.
This problem does not occur in Eclipse 2021-06 4.20.



public static void main(String[] args) {
	String s1 = hoge1(String::new);
	String s2 = hoge2(String::new);	// Error. See the attached file.
}
static <T> T hoge1(Supplier<T> sup) {
	return null;
}
static <T> T hoge2(Supplier<T>... sup) {
	return null;
}
Comment 1 Shinji Kashihara CLA 2021-09-21 22:17:03 EDT
Error description:
The target type of this expression must be a functional interface
Comment 2 Shinji Kashihara CLA 2021-09-21 22:29:26 EDT
Duplicate? bug 576152
Comment 3 Andrey Loskutov CLA 2021-09-22 00:36:15 EDT
(In reply to Shinji Kashihara from comment #2)
> Duplicate? bug 576152

Most likely, however in your example there is no overloaded method.
Comment 4 Andrey Loskutov CLA 2021-09-22 04:12:25 EDT

*** This bug has been marked as a duplicate of bug 576152 ***