[ConstraintSystem] Detect and diagnose missing member refs in key path

Key path components can reference an invalid or missing member
just like regular expressions, so we need to account for that
while trying to simplify key path constraint.
This commit is contained in:
Pavel Yaskevich
2019-10-17 12:55:04 -07:00
parent bdd68dfea0
commit 57c770238c

View File

@@ -6352,6 +6352,25 @@ ConstraintSystem::simplifyKeyPathConstraint(
anyComponentsUnresolved = true;
continue;
}
if (shouldAttemptFixes()) {
auto *componentLoc = getConstraintLocator(
keyPath, {LocatorPathElt::KeyPathComponent(i),
LocatorPathElt::KeyPathComponentResult()});
// If one of the components haven't been resolved, let's check
// whether it has been determined to be a "hole" and if so,
// let's allow component validation to contiunue.
//
// This helps to, for example, diagnose problems with missing
// members used as part of a key path.
if (isHoleAt(componentLoc)) {
anyComponentsUnresolved = true;
capability = ReadOnly;
continue;
}
}
return SolutionKind::Unsolved;
}