Bug 569498 - field "cannot be resolved to a variable" in ternary
expression as method argument with String expression type

Change-Id: Ic1a45581a7fa75bbe2f94cc630f83425d483be1a
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>(cherry picked from commit 969dd97a97297dd985f4c924014f0537a709fc52)
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java
index 3d23a15..0b9d164 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java
@@ -45,7 +45,7 @@
 // All specified tests which does not belong to the class are skipped...
 static {
 //	TESTS_PREFIX = "testBug95521";
-//	TESTS_NAMES = new String[] { "testBug83127a" };
+//	TESTS_NAMES = new String[] { "testBug566332_01" };
 //	TESTS_NUMBERS = new int[] { 21 };
 //	TESTS_RANGE = new int[] { 23, -1 };
 }
@@ -1604,6 +1604,25 @@
 			"case expressions must be constant expressions\n" +
 			"----------\n");
 }
+public void testBug569498() {
+	if (this.complianceLevel < ClassFileConstants.JDK11) {
+		return;
+	}
+	this.runNegativeTest(
+			new String[] {
+				"X.java",
+				"public class X {\n"
+				+ "	final String s1 = \"\";\n"
+				+ "	public void m(Object s) {\n"
+				+ "		final boolean b = false;\n"
+				+ "		final String s2 = \"\";\n"
+				+ "		m(b? s1 : s2);\n"
+				+ "	}\n"
+				+ "    public static void main(String[] args) {}\n"
+				+ "}",
+			},
+			"");
+}
 public static Class testClass() {
 	return ConstantTest.class;
 }
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
index 0dcd9d3..8d49d80 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
@@ -521,6 +521,9 @@
 		}
 		if (isPolyExpression()) {
 			if (this.expectedType == null || !this.expectedType.isProperType(true)) {
+				// We will be back here in case of a PolyTypeBinding. So, to enable
+				// further processing, set it back to default.
+				this.constant = Constant.NotAConstant;
 				return new PolyTypeBinding(this);
 			}
 			return this.resolvedType = computeConversions(scope, this.expectedType) ? this.expectedType : null;