Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing code implementation #1755

Closed
srikanth-sankaran opened this issue Dec 18, 2023 · 2 comments · Fixed by #2342 or #2348
Closed

Missing code implementation #1755

srikanth-sankaran opened this issue Dec 18, 2023 · 2 comments · Fixed by #2342 or #2348
Assignees

Comments

@srikanth-sankaran
Copy link
Contributor

From here: #1045 (comment)

import java.util.function.Supplier;

public class X {
	public static void main(String[] args) {
		String a = "Hello";
		if (((Supplier<String>) () -> a) instanceof Supplier)
		    System.out.print("yes");
	  	if (((Supplier<String>) () -> a) != null)
		    System.out.print("yes");

	}
}

results in Missing code implementation in the compiler error

@stephan-herrmann
Copy link
Contributor

Seeing (((Supplier<String>) () -> a) != null) we want to raise "Redundant null check: this expression cannot be null" but in ProblemReporter.expressionNonNullComparison(Expression, boolean) nobody expects the expression to be a Lambda!! (after peeling off the cast, i.e.)
:)

stephan-herrmann added a commit to stephan-herrmann/eclipse.jdt.core that referenced this issue Apr 13, 2024
stephan-herrmann added a commit that referenced this issue Apr 14, 2024
@iloveeclipse
Copy link
Member

@stephan-herrmann : the new test org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest.testGH1755() fails on all Java 17 builds with 1.7 compliance, like in https://download.eclipse.org/eclipse/downloads/drops4/I20240414-1800/testresults/html/org.eclipse.jdt.core.tests.compiler_ep432I-unit-cen64-gtk3-java17_linux.gtk.x86_64_17.html

junit.framework.ComparisonFailure: Invalid problem log .
----------- Expected ------------
----------\n
1. ERROR in X.java (at line 8)\n
if (((Supplier<String>) () -> a) != null)\n
^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n
Redundant null check: this expression cannot be null\n
----------\n

------------ but was ------------
----------\n
1. ERROR in X.java (at line 6)\n
if (((Supplier<String>) () -> a) instanceof Supplier)\n
^^^^^^^\n
Lambda expressions are allowed only at source level 1.8 or above\n
----------\n
2. ERROR in X.java (at line 6)\n
if (((Supplier<String>) () -> a) instanceof Supplier)\n
^^^^^^^\n
The target type of this expression must be a functional interface\n
----------\n
3. ERROR in X.java (at line 8)\n
if (((Supplier<String>) () -> a) != null)\n
^^^^^^^\n
Lambda expressions are allowed only at source level 1.8 or above\n
----------\n
4. ERROR in X.java (at line 8)\n
if (((Supplier<String>) () -> a) != null)\n
^^^^^^^\n
The target type of this expression must be a functional interface\n
----------\n

@iloveeclipse iloveeclipse reopened this Apr 15, 2024
stephan-herrmann added a commit to stephan-herrmann/eclipse.jdt.core that referenced this issue Apr 16, 2024
fixes eclipse-jdt#1755 after re-open:

disable test using lambda when below 1.8
iloveeclipse pushed a commit that referenced this issue Apr 16, 2024
fixes #1755 after re-open:

disable test using lambda when below 1.8
robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this issue Jul 18, 2024
robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this issue Jul 18, 2024
fixes eclipse-jdt#1755 after re-open:

disable test using lambda when below 1.8
gayanper pushed a commit to gayanper/eclipse.jdt.core that referenced this issue Sep 7, 2024
gayanper pushed a commit to gayanper/eclipse.jdt.core that referenced this issue Sep 7, 2024
fixes eclipse-jdt#1755 after re-open:

disable test using lambda when below 1.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants