Skip to content

Commit d75b0ab

Browse files
committed
Unit Test for ECJ vs JAVAC difference in behavioues in Primitives in
Patterns - issue eclipse-jdt#3535
1 parent 07f7183 commit d75b0ab

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PrimitiveInPatternsTest.java

+34-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class PrimitiveInPatternsTest extends AbstractRegressionTest9 {
2929
static {
3030
// TESTS_NUMBERS = new int [] { 1 };
3131
// TESTS_RANGE = new int[] { 1, -1 };
32-
// TESTS_NAMES = new String[] { "testIssue3505" };
32+
// TESTS_NAMES = new String[] { "testIssue3535" };
3333
}
3434
private String extraLibPath;
3535
public static Class<?> testClass() {
@@ -7416,4 +7416,37 @@ public T get() {
74167416
"1");
74177417
}
74187418

7419+
public void testIssue3535() {
7420+
runConformTest(new String[] {
7421+
"X.java",
7422+
"""
7423+
public class X {
7424+
7425+
static Integer getInteger() {
7426+
return Integer.MIN_VALUE;
7427+
}
7428+
public int foo() {
7429+
Integer i = 10;
7430+
Y<Integer> f = new Y<>();
7431+
f.put(X.getInteger()); // This makes all the difference
7432+
return f.get() instanceof float ? 3 : 2;
7433+
}
7434+
public static void main(String[] args) {
7435+
System.out.println(new X().foo());
7436+
}
7437+
7438+
}
7439+
class Y <T> {
7440+
T t;
7441+
T get() {
7442+
return t;
7443+
}
7444+
void put( T t) {
7445+
this.t = t;
7446+
}
7447+
}
7448+
"""
7449+
},
7450+
"3");
7451+
}
74197452
}

0 commit comments

Comments
 (0)