Bug 576174 - Compile error: Variable length argument + Method reference
Summary: Compile error: Variable length argument + Method reference
Status: CLOSED DUPLICATE of bug 576152
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.21   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2021-09-21 22:07 EDT by Shinji Kashihara CLA
Modified: 2021-09-22 04:12 EDT (History)
1 user (show)

See Also:


Attachments
Compile error: Variable length argument + Method reference (64.84 KB, image/png)
2021-09-21 22:07 EDT, Shinji Kashihara CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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 ***