This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270727

Summary: NetBeans produces incorrect type checking on streams without generic suppliers.
Product: java Reporter: brettryan <brettryan>
Component: SourceAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal Keywords: REGRESSION
Priority: P3    
Version: Dev   
Hardware: PC   
OS: Mac OS X   
Issue Type: DEFECT Exception Reporter:

Description brettryan 2017-05-24 07:57:19 UTC
When using a stream collector with a supplier producing a non-generic formed collection NetBeans thinks the result is of type Object, though this compiles fine.

this was fine in 8.2 and earlier dev builds.

The most basic form is:

    // compiles fine, netbeans errors thinking the type is Object
    Set res = toCollection(() -> new TreeSet())

In the following sets 1 and 3 produce an error though they are both valid.

    List<String> list = new ArrayList<>();
    Set<String> set1 = list.stream().collect(toCollection(()
            -> new TreeSet(String.CASE_INSENSITIVE_ORDER)));
    Set<String> set2 = list.stream().collect(toCollection(()
            -> new TreeSet<>(String.CASE_INSENSITIVE_ORDER)));
    Set<String> set3 = list.stream().collect(toCollection(() -> new TreeSet()));
    Set<String> set4 = list.stream().collect(toCollection(() -> new TreeSet<>()));
    Set<String> set5 = list.stream().collect(toCollection(TreeSet::new));
    Set<String> set6 = list.stream().collect(toSet());


Product Version: NetBeans IDE Dev (Build 201705170001)
Java: 1.8.0_131; Java HotSpot(TM) 64-Bit Server VM 25.131-b11
Runtime: Java(TM) SE Runtime Environment 1.8.0_131-b11
System: Mac OS X version 10.12.4 running on x86_64; UTF-8; en_AU (nb)
User directory: /Users/bryan/Library/Application Support/NetBeans/dev
Cache directory: /Users/bryan/Library/Caches/NetBeans/dev