1137 static class PolyScanner extends FilterScanner {
1138
1139 PolyScanner() {
1140 super(EnumSet.of(CONDEXPR, PARENS, LAMBDA, REFERENCE));
1141 }
1142 }
1143
1144 /**
1145 * A tree scanner suitable for visiting the target-type dependent nodes nested
1146 * within a lambda expression body.
1147 */
1148 static class LambdaReturnScanner extends FilterScanner {
1149
1150 LambdaReturnScanner() {
1151 super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP,
1152 FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
1153 }
1154 }
1155
1156 /**
1157 * This visitor is used to check that structural expressions conform
1158 * to their target - this step is required as inference could end up
1159 * inferring types that make some of the nested expressions incompatible
1160 * with their corresponding instantiated target
1161 */
1162 class CheckStuckPolicy extends PolyScanner implements DeferredStuckPolicy, Infer.FreeTypeListener {
1163
1164 Type pt;
1165 InferenceContext inferenceContext;
1166 Set<Type> stuckVars = new LinkedHashSet<>();
1167 Set<Type> depVars = new LinkedHashSet<>();
1168
1169 @Override
1170 public boolean isStuck() {
1171 return !stuckVars.isEmpty();
1172 }
1173
1174 @Override
1175 public Set<Type> stuckVars() {
1176 return stuckVars;
|
1137 static class PolyScanner extends FilterScanner {
1138
1139 PolyScanner() {
1140 super(EnumSet.of(CONDEXPR, PARENS, LAMBDA, REFERENCE));
1141 }
1142 }
1143
1144 /**
1145 * A tree scanner suitable for visiting the target-type dependent nodes nested
1146 * within a lambda expression body.
1147 */
1148 static class LambdaReturnScanner extends FilterScanner {
1149
1150 LambdaReturnScanner() {
1151 super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP,
1152 FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
1153 }
1154 }
1155
1156 /**
1157 * A tree scanner suitable for visiting the target-type dependent nodes nested
1158 * within a switch expression body.
1159 */
1160 static class SwitchExpressionScanner extends FilterScanner {
1161
1162 SwitchExpressionScanner() {
1163 super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP,
1164 FORLOOP, IF, BREAK, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
1165 }
1166 }
1167
1168 /**
1169 * This visitor is used to check that structural expressions conform
1170 * to their target - this step is required as inference could end up
1171 * inferring types that make some of the nested expressions incompatible
1172 * with their corresponding instantiated target
1173 */
1174 class CheckStuckPolicy extends PolyScanner implements DeferredStuckPolicy, Infer.FreeTypeListener {
1175
1176 Type pt;
1177 InferenceContext inferenceContext;
1178 Set<Type> stuckVars = new LinkedHashSet<>();
1179 Set<Type> depVars = new LinkedHashSet<>();
1180
1181 @Override
1182 public boolean isStuck() {
1183 return !stuckVars.isEmpty();
1184 }
1185
1186 @Override
1187 public Set<Type> stuckVars() {
1188 return stuckVars;
|