Community
Participate
Working Groups
+++ This bug was initially created as a clone of Bug #488495 +++ Using Eclipse 4.6-I20160223-0800 After using a few stream methods, it seems that the null constraints get lost. For example, in this code: @NonNullByDefault public class Main { public static void main(String[] args, Set<String> set) { Optional<@Nullable String> kam = set.stream() .map(trace -> getString(String.class)) .findFirst(); // Null type safety (type annotations): The expression of type 'Optional<String>' needs unchecked conversion to conform to 'Optional<@Nullable String>' System.out.println(kam); } public @Nullable static <T extends CharSequence> T getString(Class<T> moduleClass) { return null; } } After the map, it should be a stream of @Nullable String but instead it's just String (can be verified with hover). Because of that, findFirst returns an Optional<String> instead of Optional<@Nullable String> I attached a sample project for convenience.
Spawned off bug 488495 after investigation only concerned a second (similar) example. The attachment mentioned is attachment 259931 [details]
As of bug 488495 comment 12 I wonder whether the transfer of null hints in BoundSet.incorporate() (under if(analyzeNull)) should differentiate the bound kinds SUBTYPE and SUPERTYPE to determine in which direction a null hint should flow. I'm not sure this is related to this current bug but I will check via this bug anyway.
bulk move out of 4.8
Bulk move out of 4.9