| Summary: | [1.8][null]Missing warnings when using Wildcards with null annotations | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Till Brychcy <register.eclipse> |
| Component: | Core | Assignee: | Till Brychcy <register.eclipse> |
| Status: | VERIFIED FIXED | QA Contact: | Stephan Herrmann <stephan.herrmann> |
| Severity: | normal | ||
| Priority: | P3 | CC: | dusisarath, manoj.palat, stephan.herrmann |
| Version: | 4.5.1 | ||
| Target Milestone: | 4.6 M6 | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| See Also: |
https://git.eclipse.org/r/63686 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=e2fc6e7db19ada9b01733b33b99936b7344de6b1 |
||
| Whiteboard: | |||
|
Description
Till Brychcy
DESCRIPTION:
During compilation of the following code, only "warning 3" is reported:
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
public class WildCardNullable {
static class A<T> {
@Nullable
T returnNull() {
return null;
}
void acceptNonNullT(@NonNull T t) {
}
void acceptNonNullObject(@NonNull Object x) {
}
}
static @NonNull Number g(A<? extends @NonNull Number> a) {
return a.returnNull(); // error 1 expected
}
public static final <T> void map(final A<@NonNull ? super T> a, T t) {
a.acceptNonNullT(t); // warning 2 expected
a.acceptNonNullObject(t); // warning 3 expected
}
}
ANALYSIS:
In NullAnnotationMatching.areSameTypes, for capture bindings, the null bits are not compared if the bounds were found.
PATCH (via gerrit):
compare the null bits in these cases. adjust testBug448709 so it expects are warning, too.
New Gerrit change created: https://git.eclipse.org/r/63686 This didn't have Target Milestone at all, feel free to correct it if you plan to look at this later. Looks good to me. Looking at the change in testBug448709() I only added one more (stripped-down) variant of that test, witnessing that the new warning is *not* raised, when flow analysis knows that the value is nonnull. Rebased, test added and re-uploaded to gerrit. Gerrit change https://git.eclipse.org/r/63686 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=e2fc6e7db19ada9b01733b33b99936b7344de6b1 (In reply to Eclipse Genie from comment #5) > Gerrit change https://git.eclipse.org/r/63686 was merged to [master]. > Commit: > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=e2fc6e7db19ada9b01733b33b99936b7344de6b1 > Released for 4.6 M6. Thanks! Didn't find UI option for pessimistic null analysis for free type variables. After manually adding the same I could reproduce the mentioned scenario in comment 1. Verified for 4.6M6 using Version: Neon (4.6) Build id: I20160314-2000 (In reply to Dusi Sarath Chandra from comment #7) > Didn't find UI option for pessimistic null analysis for free type variables. I assume this got resolved by using a more recent build, right? |