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

Bug 571481

Summary: Improve the way how code assist detect variable types with lambdas
Product: [Eclipse Project] JDT Reporter: Cristiano Gaviao <cvgaviao>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 4.20   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Cristiano Gaviao CLA 2021-02-24 22:36:30 EST
I'm working with some scenarios using lambdas and sometimes I can't have the right type for variables with the code assist.

In the example below, the type of 'prov' should be Optional<Provider<WebHandlerProvider>> but code assist is creating a local variable as Optional<Object>. 

    ServiceLoader<WebHandlerProvider> loader = ServiceLoader.load(WebHandlerProvider.class);

    for (ConfigWebHandler wh : pRouteConfig.getHandlers()) {
      try {
        Optional<Object> prov = loader
            .stream()
            .filter(t -> {
              WebHandlerTag ann = t.type()
                                   .getAnnotation(WebHandlerTag.class);
              return ann != null
                  && ann.id().equals(wh.getId())
                  && Version.parseVersion(ann.version())
                            .equals(wh.getVersion());
            })
            .findFirst()
            .map(Provider::get);
       
       providers.add(prov.);
      }