changeset 3196:f6740b308ee2

8037789: Surprising more-specific results for lambda bodies with no return expressions Reviewed-by: mcimadamore, vromero
author dlsmith
date Fri, 08 Jan 2016 12:29:02 -0700
parents 88a874f33d6d
children 9571d628ecf6
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
diffstat 1 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Jan 08 17:14:10 2016 +0100
+++ b/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<JCExpression> 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);
                         }
                     }
                 }