@@ -2308,47 +2308,38 @@ bool ConstraintSystem::solveSimplified(
2308
2308
allowFreeTypeVariables);
2309
2309
}
2310
2310
2311
- // If there are no disjunctions, we can't solve this system.
2311
+ // If there are no disjunctions we can't solve this system unless we have
2312
+ // free type variables and are allowing them in the solution.
2312
2313
if (disjunctions.empty ()) {
2313
- // If the only remaining constraints are conformance constraints
2314
- // or member equality constraints, and we're allowed to have free
2315
- // variables, we still have a solution. FIXME: It seems like this
2316
- // should be easier to detect. Aren't there other kinds of
2317
- // constraints that could show up here?
2318
- if (allowFreeTypeVariables != FreeTypeVariableBinding::Disallow &&
2319
- hasFreeTypeVariables ()) {
2320
-
2321
- // If this solution is worse than the best solution we've seen so far,
2322
- // skip it.
2323
- if (worseThanBestSolution ())
2324
- return true ;
2314
+ if (allowFreeTypeVariables == FreeTypeVariableBinding::Disallow ||
2315
+ !hasFreeTypeVariables ())
2316
+ return true ;
2325
2317
2326
- bool anyNonConformanceConstraints = false ;
2327
- for (auto &constraint : InactiveConstraints) {
2328
- switch (constraint.getClassification ()) {
2329
- case ConstraintClassification::Relational:
2330
- case ConstraintClassification::Member:
2331
- continue ;
2332
- default :
2333
- break ;
2334
- }
2318
+ // If this solution is worse than the best solution we've seen so far,
2319
+ // skip it.
2320
+ if (worseThanBestSolution ())
2321
+ return true ;
2335
2322
2336
- anyNonConformanceConstraints = true ;
2337
- break ;
2323
+ // If we only have relational or member constraints and are allowing
2324
+ // free type variables, save the solution.
2325
+ for (auto &constraint : InactiveConstraints) {
2326
+ switch (constraint.getClassification ()) {
2327
+ case ConstraintClassification::Relational:
2328
+ case ConstraintClassification::Member:
2329
+ continue ;
2330
+ default :
2331
+ return true ;
2338
2332
}
2333
+ }
2339
2334
2340
- if (!anyNonConformanceConstraints) {
2341
- auto solution = finalize (allowFreeTypeVariables);
2342
- if (TC.getLangOpts ().DebugConstraintSolver ) {
2343
- auto &log = getASTContext ().TypeCheckerDebug ->getStream ();
2344
- log.indent (solverState->depth * 2 ) << " (found solution)\n " ;
2345
- }
2346
-
2347
- solutions.push_back (std::move (solution));
2348
- return false ;
2349
- }
2335
+ auto solution = finalize (allowFreeTypeVariables);
2336
+ if (TC.getLangOpts ().DebugConstraintSolver ) {
2337
+ auto &log = getASTContext ().TypeCheckerDebug ->getStream ();
2338
+ log.indent (solverState->depth * 2 ) << " (found solution)\n " ;
2350
2339
}
2351
- return true ;
2340
+
2341
+ solutions.push_back (std::move (solution));
2342
+ return false ;
2352
2343
}
2353
2344
2354
2345
// Pick the smallest disjunction.
0 commit comments