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 (+28 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
				"interface I {\n" +
6859
				"	String sam();\n" +
6860
				"}\n" +
6861
				"public class X {\n" +
6862
				"	static String foo(I i) { return \"\"; }\n" +
6863
				"	public static void main(String[] args) {\n" +
6864
				"		foo(() -> foo(X::getInt));\n" +
6865
				"	}\n" +
6866
				"	static Integer getInt() { return 0; }\n" +
6867
				"}\n"
6868
		},
6869
		"----------\n" + 
6870
		"1. ERROR in X.java (at line 7)\n" +
6871
		"	foo(() -> foo(X::getInt));\n" +
6872
		"	              ^^^^^^^^^\n" +
6873
		"The type of getInt() from the type X is Integer, this is incompatible with the descriptor's return type: String\n" + 
6874
		"----------\n",
6875
		null /* no extra class libraries */,
6876
		true /* flush output directory */,
6877
		null /* custom options */
6878
	);
6879
}
6852
public static Class testClass() {
6880
public static Class testClass() {
6853
	return NegativeLambdaExpressionsTest.class;
6881
	return NegativeLambdaExpressionsTest.class;
6854
}
6882
}
6855
}
6883
}
(-)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