langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java
changeset 39589 0cbaed77814c
parent 38832 759100b68651
child 39599 3c7da4996d8c
equal deleted inserted replaced
39588:a30039aaca6c 39589:0cbaed77814c
    54 import java.util.Collections;
    54 import java.util.Collections;
    55 import java.util.EnumSet;
    55 import java.util.EnumSet;
    56 import java.util.HashMap;
    56 import java.util.HashMap;
    57 import java.util.HashSet;
    57 import java.util.HashSet;
    58 import java.util.Map;
    58 import java.util.Map;
       
    59 import java.util.Optional;
    59 import java.util.Properties;
    60 import java.util.Properties;
    60 import java.util.Set;
    61 import java.util.Set;
    61 import java.util.function.BiFunction;
    62 import java.util.function.BiFunction;
    62 import java.util.function.BiPredicate;
    63 import java.util.function.BiPredicate;
    63 
    64 
   673                     return types.createErrorType(funcInterface);
   674                     return types.createErrorType(funcInterface);
   674                 }
   675                 }
   675                 paramTypes = paramTypes.tail;
   676                 paramTypes = paramTypes.tail;
   676             }
   677             }
   677 
   678 
   678             try {
       
   679                 funcInterfaceContext.solve(funcInterfaceContext.boundedVars(), types.noWarnings);
       
   680             } catch (InferenceException ex) {
       
   681                 checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
       
   682             }
       
   683 
       
   684             List<Type> actualTypeargs = funcInterface.getTypeArguments();
   679             List<Type> actualTypeargs = funcInterface.getTypeArguments();
   685             for (Type t : funcInterfaceContext.undetvars) {
   680             for (Type t : funcInterfaceContext.undetvars) {
   686                 UndetVar uv = (UndetVar)t;
   681                 UndetVar uv = (UndetVar)t;
   687                 if (uv.getInst() == null) {
   682                 Optional<Type> inst = uv.getBounds(InferenceBound.EQ).stream()
   688                     uv.setInst(actualTypeargs.head);
   683                         .filter(b -> !b.containsAny(formalInterface.getTypeArguments())).findFirst();
   689                 }
   684                 uv.setInst(inst.orElse(actualTypeargs.head));
   690                 actualTypeargs = actualTypeargs.tail;
   685                 actualTypeargs = actualTypeargs.tail;
   691             }
   686             }
   692 
   687 
   693             Type owntype = funcInterfaceContext.asInstType(formalInterface);
   688             Type owntype = funcInterfaceContext.asInstType(formalInterface);
   694             if (!chk.checkValidGenericType(owntype)) {
   689             if (!chk.checkValidGenericType(owntype)) {