Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2016-03-16 17:12:03 +0000
committerStephan Herrmann2016-05-16 14:08:58 +0000
commit78439d31c46454ce758b8068b8dcf447748481a2 (patch)
tree332b4a7e44ba45f64b3b19c74bdf358867474d9d
parentd79e22d697b98ce1a4364e5b76b1cc668ae38e6e (diff)
downloadeclipse.jdt.core-78439d31c46454ce758b8068b8dcf447748481a2.tar.gz
eclipse.jdt.core-78439d31c46454ce758b8068b8dcf447748481a2.tar.xz
eclipse.jdt.core-78439d31c46454ce758b8068b8dcf447748481a2.zip
Bug 488495 - [null] Wrong warning about unchecked conversion. I20160516-2000
Fix for collector-example Change-Id: I9b33cfed65df1707ecdbabc865c1c4347e3fae9b Signed-off-by: Till Brychcy <register.eclipse@brychcy.de>
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java35
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java10
2 files changed, 42 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
index fa4d24a5e5..acd9c87fed 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullTypeAnnotationTest.java
@@ -12254,4 +12254,39 @@ public void testBug492327() {
""
);
}
+public void testBug488495collector() {
+ runConformTestWithLibs(
+ new String[] {
+ "test/Test.java",
+ "package test;\n" +
+ "\n" +
+ "import org.eclipse.jdt.annotation.NonNullByDefault;\n" +
+ "\n" +
+ "interface Collector<A, R> {\n" +
+ "}\n" +
+ "\n" +
+ "interface Stream {\n" +
+ " <A1, R1> R1 collect(Collector<A1, R1> collector);\n" +
+ "}\n" +
+ "\n" +
+ "interface List<E> {\n" +
+ "}\n" +
+ "\n" +
+ "@NonNullByDefault\n" +
+ "public class Test {\n" +
+ " public static <T> Collector<?, List<T>> toList() {\n" +
+ " return new Collector<Object, List<T>>(){};\n" +
+ " }\n" +
+ "\n" +
+ " public static List<String> myMethod(Stream stream) {\n" +
+ " List<String> list = stream.collect(toList());\n" +
+ " return list;\n" +
+ " }\n" +
+ "}\n" +
+ "",
+ },
+ getCompilerOptions(),
+ ""
+ );
+}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
index 5ae1f3cdc9..a004158365 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java
@@ -673,9 +673,13 @@ class BoundSet {
// not per JLS: if the new constraint relates types where at least one has a null annotations,
// record all null tagBits as hints for the final inference solution.
long nullHints = (newConstraint.left.tagBits | newConstraint.right.tagBits) & TagBits.AnnotationNullMASK;
- if (nullHints != 0 && TypeBinding.equalsEquals(boundI.left, boundJ.left)) {
- boundI.nullHints |= nullHints;
- boundJ.nullHints |= nullHints;
+ if (nullHints != 0) {
+ if (TypeBinding.equalsEquals(boundI.left, boundJ.left)
+ || (boundI.relation == ReductionResult.SAME && TypeBinding.equalsEquals(boundI.right, boundJ.left))
+ || (boundJ.relation == ReductionResult.SAME && TypeBinding.equalsEquals(boundI.left, boundJ.right))) {
+ boundI.nullHints |= nullHints;
+ boundJ.nullHints |= nullHints;
+ }
}
}
}

Back to the top