mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
RequirementMachine: Conditional requirement inference
If a type parameter is subject to both a conformance requirement and a concrete type requirement, the concrete type might conform conditionally. In this case, introduce new requirements to satisfy the conditional conformance. Since this can add new hitherto-unseen protocols to the rewrite system, restrict this feature to top-level generic signatures, and not protocol requirement signatures. Allowing this to occur in protocol requirement signatures would change the connectivity of the protocol dependency graph (and hence the connected components) during completion, which would be a major complication in the design. The GSB already enforces this restriction. I changed the existing conditional_requirement_inference.swift test to run with -requirement-machine-inferred-signatures=verify. Since one of the test cases there triggers an unrelated bug in the Requirement Machine, I split it off into a new file named conditional_requirement_inference_2.swift which still runs with the GSB. Once the bug is fixed I'll merge the files again.
This commit is contained in:
@@ -264,6 +264,10 @@ private:
|
||||
ProtocolConformance *concrete,
|
||||
AssociatedTypeDecl *assocType) const;
|
||||
|
||||
void inferConditionalRequirements(
|
||||
ProtocolConformance *concrete,
|
||||
ArrayRef<Term> substitutions) const;
|
||||
|
||||
MutableTerm computeConstraintTermForTypeWitness(
|
||||
Term key, RequirementKind requirementKind,
|
||||
CanType concreteType, CanType typeWitness,
|
||||
@@ -284,4 +288,4 @@ private:
|
||||
|
||||
} // end namespace swift
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user