mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CS] Always eagerly bind member type var to hole for missing member
We know this is where the issue is so we ought to always produce a concrete hole.
This commit is contained in:
@@ -11604,22 +11604,11 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
|
||||
// `key path` constraint can't be retired until all components
|
||||
// are simplified.
|
||||
addTypeVariableConstraintsToWorkList(memberTypeVar);
|
||||
} else if (isa<Expr *>(locator->getAnchor()) &&
|
||||
!getSemanticsProvidingParentExpr(
|
||||
getAsExpr(locator->getAnchor()))) {
|
||||
// If there are no contextual expressions that could provide
|
||||
// a type for the member type variable, let's default it to
|
||||
// a placeholder eagerly so it could be propagated to the
|
||||
// pattern if necessary.
|
||||
recordTypeVariablesAsHoles(memberTypeVar);
|
||||
} else if (locator->isLastElement<LocatorPathElt::PatternMatch>()) {
|
||||
// Let's handle member patterns specifically because they use
|
||||
// equality instead of argument application constraint, so allowing
|
||||
// them to bind member could mean missing valid hole positions in
|
||||
// the pattern.
|
||||
recordTypeVariablesAsHoles(memberTypeVar);
|
||||
} else {
|
||||
recordPotentialHole(memberTypeVar);
|
||||
// Eagerly turn the member type variable into a hole since we know
|
||||
// this is where the issue is and we've recorded a fix for it. This
|
||||
// avoids producing unnecessary holes for e.g generic parameters.
|
||||
recordTypeVariablesAsHoles(memberTypeVar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user