Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 441338

Summary: [1.8][null] better combine null type annotations on substitution of parameterized type
Product: [Eclipse Project] JDT Reporter: Stephan Herrmann <stephan.herrmann>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, manoj.palat, shankhba
Version: 4.4   
Target Milestone: 4.5 M2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
patch under test none

Description Stephan Herrmann CLA 2014-08-07 07:48:02 EDT
Function TypeBinding.unannotated(boolean) from 438458 is over-eager as can be shown by this test:

interface I2<T,U extends List<T>> {
        @NonNull U getU();
}
class Main {    
        static String test (I2<@Nullable String, @Nullable ArrayList<@Nullable String>> i2) {
                return i2.getU().get(0).toUpperCase(); 
        }
}


While '@NonNull U' overrides the '@Nullable' annotation on the ArrayList type argument for I2, the detail '@Nullable String' must be kept to produce the proper error against the final toUpperCase().
IOW, the return type of i2.getU() must be:
   @NonNull ArrayList<@Nullable String>
the inner @Nullable is currently dropped.
Comment 1 Stephan Herrmann CLA 2014-08-07 07:49:00 EDT
(In reply to Stephan Herrmann from comment #0)
> Function TypeBinding.unannotated(boolean) from 438458 is over-eager as can
> be shown by this test:

clickable ref: bug 438458
Comment 2 Stephan Herrmann CLA 2014-08-07 07:51:08 EDT
Created attachment 245800 [details]
patch under test

This is the change I'm currently testing on top of all my changes pending for 4.4.1.

The additional changes in BoundSet simply enhance safety not to unnecessarily produce contradictory annotations.
Comment 3 Stephan Herrmann CLA 2014-08-07 09:41:10 EDT
Modified patch passed all tests in R4_4_maintenance.
Comment 4 Stephan Herrmann CLA 2014-08-14 12:42:52 EDT
Tests released via http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=dc74cb9ccf05bc2089bda4773412bb0387d8bf2f

Other than that this bug has been subsumed by bug 441693

*** This bug has been marked as a duplicate of bug 441693 ***
Comment 5 shankha banerjee CLA 2014-09-16 11:50:31 EDT
Verified for Mars 4.5M2 using I20140915-2000 build.