Community
Participate
Working Groups
@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 } }
(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.
> I opt for: "fix". +1
Fix was straight-forward by respecting LocalTypeBinding.enclosingMethod when searching for an applicable default. Release for 3.8 M5 via commit 62b97f10b8bb4123dfea4bccabc125ecea6ba019
Verified for 3.8 M5 using build id: I20120122-2000