# HG changeset patch # User dlsmith # Date 1452281342 25200 # Node ID eaba62b5d8e29f4dc3b1acbffc1f53428cb31e5f # Parent ff8be37d1164ccfbbeb806c0af1e91aa631343d4 8037789: Surprising more-specific results for lambda bodies with no return expressions Reviewed-by: mcimadamore, vromero diff -r ff8be37d1164 -r eaba62b5d8e2 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jan 08 17:14:10 2016 +0100 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jan 08 12:29:02 2016 -0700 @@ -1219,18 +1219,21 @@ result &= true; } else if (ret_t.hasTag(VOID)) { result &= false; - } else if (unrelatedFunctionalInterfaces(ret_t, ret_s)) { - for (JCExpression expr : lambdaResults(tree)) { - result &= functionalInterfaceMostSpecific(ret_t, ret_s, expr); + } else { + List lambdaResults = lambdaResults(tree); + if (!lambdaResults.isEmpty() && unrelatedFunctionalInterfaces(ret_t, ret_s)) { + for (JCExpression expr : lambdaResults) { + result &= functionalInterfaceMostSpecific(ret_t, ret_s, expr); + } + } else if (!lambdaResults.isEmpty() && ret_t.isPrimitive() != ret_s.isPrimitive()) { + for (JCExpression expr : lambdaResults) { + boolean retValIsPrimitive = expr.isStandalone() && expr.type.isPrimitive(); + result &= (retValIsPrimitive == ret_t.isPrimitive()) && + (retValIsPrimitive != ret_s.isPrimitive()); + } + } else { + result &= compatibleBySubtyping(ret_t, ret_s); } - } else if (ret_t.isPrimitive() != ret_s.isPrimitive()) { - for (JCExpression expr : lambdaResults(tree)) { - boolean retValIsPrimitive = expr.isStandalone() && expr.type.isPrimitive(); - result &= (retValIsPrimitive == ret_t.isPrimitive()) && - (retValIsPrimitive != ret_s.isPrimitive()); - } - } else { - result &= compatibleBySubtyping(ret_t, ret_s); } } }