Bug 365836 - [compiler][null] Incomplete propagation of null defaults.
Summary: [compiler][null] Incomplete propagation of null defaults.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.8 M5   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-07 03:26 EST by Srikanth Sankaran CLA
Modified: 2012-01-24 09:50 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2011-12-07 03:26:30 EST
@NonNullByDefault applied at a method level does not get
propagated to the local types of the method. Either we need
to fix this or at least clarify semantics.

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

// @NonNullByDefault
public class X {
    @NonNullByDefault 
    public void foo(@Nullable String [] args) {
        class local {
            void zoo(Object o) {

            }
        };
        new local().zoo(null); // No error with defaults applying to foo
    }
}
Comment 1 Stephan Herrmann CLA 2011-12-07 04:46:34 EST
(In reply to comment #0)
> @NonNullByDefault applied at a method level does not get
> propagated to the local types of the method. Either we need
> to fix this or at least clarify semantics.

I opt for: "fix".
Scopes for these defaults should not have "holes".

Obviously enclosing methods are not considered while searching
for a default, but should be.
Comment 2 Markus Keller CLA 2011-12-07 07:28:09 EST
> I opt for: "fix".
+1
Comment 3 Stephan Herrmann CLA 2011-12-19 14:55:14 EST
Fix was straight-forward by respecting LocalTypeBinding.enclosingMethod when searching
for an applicable default.

Release for 3.8 M5 via commit 62b97f10b8bb4123dfea4bccabc125ecea6ba019
Comment 4 Srikanth Sankaran CLA 2012-01-24 09:50:54 EST
Verified for 3.8 M5 using build id: I20120122-2000