Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 412650 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java (+32 lines)
Lines 6847-6855 Link Here
6847
		null /* no extra class libraries */,
6847
		null /* no extra class libraries */,
6848
		true /* flush output directory */,
6848
		true /* flush output directory */,
6849
		null /* custom options */
6849
		null /* custom options */
6850
	);
6850
	);
6851
}
6851
}
6852
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=412650
6853
// [1.8][compiler]Incongruent Lambda Exception thrown
6854
public void test412650() {
6855
	this.runNegativeTest(
6856
		new String[] {
6857
				"X.java",
6858
				"package test;\n" +
6859
				"import static test.Y.*;\n" +
6860
				"public class X  {\n" +
6861
				"  public void foo() {\n" +
6862
				"    Y<String> generated = cons(\"a\", () -> cons(\"b\", Y::<String>empty));\n" +
6863
				"  }\n" +
6864
				"}\n",
6865
				"Y.java",
6866
				"package test;\n" +
6867
				"import java.util.function.Supplier;\n" +
6868
				"public abstract class Y<E>  {\n" +
6869
				"  public static <E> Y<E> empty() { return null;}\n" +
6870
				"  public static <E> Y<E> cons(E head, Supplier<Y<E>> tailFun) {return null;}\n" +
6871
				"}\n"
6872
		},
6873
		"----------\n" + 
6874
		"1. ERROR in X.java (at line 5)\n" + 
6875
		"	Y<String> generated = cons(\"a\", () -> cons(\"b\", Y::<String>empty));\n" + 
6876
		"	                                                ^^^^^^^^^^^^^^^^\n" +
6877
		"The type of empty() from the type Y is Y<Object>, this is incompatible with the descriptor's return type: Y<E>\n" + 
6878
		"----------\n",
6879
		null /* no extra class libraries */,
6880
		true /* flush output directory */,
6881
		null /* custom options */
6882
	);
6883
}
6852
public static Class testClass() {
6884
public static Class testClass() {
6853
	return NegativeLambdaExpressionsTest.class;
6885
	return NegativeLambdaExpressionsTest.class;
6854
}
6886
}
6855
}
6887
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java (+2 lines)
Lines 575-584 Link Here
575
		setExpectedType(left);
575
		setExpectedType(left);
576
		IErrorHandlingPolicy oldPolicy = this.enclosingScope.problemReporter().switchErrorHandlingPolicy(silentErrorHandlingPolicy);
576
		IErrorHandlingPolicy oldPolicy = this.enclosingScope.problemReporter().switchErrorHandlingPolicy(silentErrorHandlingPolicy);
577
		try {
577
		try {
578
			this.binding = null;
578
			this.binding = null;
579
			resolveType(this.enclosingScope);
579
			resolveType(this.enclosingScope);
580
		} catch (IncongruentLambdaException e) {
581
			return false;
580
		} finally {
582
		} finally {
581
			this.enclosingScope.problemReporter().switchErrorHandlingPolicy(oldPolicy);
583
			this.enclosingScope.problemReporter().switchErrorHandlingPolicy(oldPolicy);
582
			isCompatible = this.binding != null && this.binding.isValidBinding();
584
			isCompatible = this.binding != null && this.binding.isValidBinding();
583
			if (isCompatible) {
585
			if (isCompatible) {
584
				if (this.resultExpressions == null)
586
				if (this.resultExpressions == null)

Return to bug 412650