< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java

Print this page

1294             }
1295 
1296             /**
1297              * Tests whether one functional interface type can be considered more specific
1298              * than another unrelated functional interface type for the scanned expression.
1299              */
1300             class MostSpecificFunctionReturnChecker extends DeferredAttr.PolyScanner {
1301 
1302                 final Type tRet;
1303                 final Type sRet;
1304                 boolean result;
1305 
1306                 /** Parameters {@code t} and {@code s} are unrelated functional interface types. */
1307                 MostSpecificFunctionReturnChecker(Type tRet, Type sRet) {
1308                     this.tRet = tRet;
1309                     this.sRet = sRet;
1310                     result = true;
1311                 }
1312 
1313                 @Override
1314                 void skip(JCTree tree) {
1315                     result = false;
1316                 }
1317 
1318                 @Override
1319                 public void visitConditional(JCConditional tree) {
1320                     scan(asExpr(tree.truepart));
1321                     scan(asExpr(tree.falsepart));
1322                 }
1323 
1324                 @Override
1325                 public void visitReference(JCMemberReference tree) {
1326                     if (sRet.hasTag(VOID)) {
1327                         // do nothing
1328                     } else if (tRet.hasTag(VOID)) {
1329                         result = false;
1330                     } else if (tRet.isPrimitive() != sRet.isPrimitive()) {
1331                         boolean retValIsPrimitive =
1332                                 tree.refPolyKind == PolyKind.STANDALONE &&
1333                                 tree.sym.type.getReturnType().isPrimitive();
1334                         result &= (retValIsPrimitive == tRet.isPrimitive()) &&

1294             }
1295 
1296             /**
1297              * Tests whether one functional interface type can be considered more specific
1298              * than another unrelated functional interface type for the scanned expression.
1299              */
1300             class MostSpecificFunctionReturnChecker extends DeferredAttr.PolyScanner {
1301 
1302                 final Type tRet;
1303                 final Type sRet;
1304                 boolean result;
1305 
1306                 /** Parameters {@code t} and {@code s} are unrelated functional interface types. */
1307                 MostSpecificFunctionReturnChecker(Type tRet, Type sRet) {
1308                     this.tRet = tRet;
1309                     this.sRet = sRet;
1310                     result = true;
1311                 }
1312 
1313                 @Override
1314                 protected void skip(JCTree tree) {
1315                     result = false;
1316                 }
1317 
1318                 @Override
1319                 public void visitConditional(JCConditional tree) {
1320                     scan(asExpr(tree.truepart));
1321                     scan(asExpr(tree.falsepart));
1322                 }
1323 
1324                 @Override
1325                 public void visitReference(JCMemberReference tree) {
1326                     if (sRet.hasTag(VOID)) {
1327                         // do nothing
1328                     } else if (tRet.hasTag(VOID)) {
1329                         result = false;
1330                     } else if (tRet.isPrimitive() != sRet.isPrimitive()) {
1331                         boolean retValIsPrimitive =
1332                                 tree.refPolyKind == PolyKind.STANDALONE &&
1333                                 tree.sym.type.getReturnType().isPrimitive();
1334                         result &= (retValIsPrimitive == tRet.isPrimitive()) &&
< prev index next >