RequirementMachine: Introduce TypeAliasRequirementsRequest

This is a verbatim copy of the GenericSignatureBuilder's somewhat
questionable (but necessary for source compatibility) logic where
protocol typealiases with the same name as some other associated
type imply a same-type requirement.

The related diagnostics are there too, but only emitted when
-requirement-machine-protocol-signatures=on; in 'verify' mode,
the GSB will emit the same diagnostics.
This commit is contained in:
Slava Pestov
2021-11-19 14:31:09 -05:00
parent 17f1cf9297
commit 28c1178c4f
6 changed files with 339 additions and 4 deletions

View File

@@ -4225,6 +4225,7 @@ class ProtocolDecl final : public NominalTypeDecl {
friend class SuperclassDeclRequest;
friend class SuperclassTypeRequest;
friend class StructuralRequirementsRequest;
friend class TypeAliasRequirementsRequest;
friend class ProtocolDependenciesRequest;
friend class RequirementSignatureRequest;
friend class RequirementSignatureRequestRQM;
@@ -4421,6 +4422,11 @@ public:
/// instead.
ArrayRef<StructuralRequirement> getStructuralRequirements() const;
/// Retrieve same-type requirements implied by protocol typealiases with the
/// same name as associated types, and diagnose cases that are better expressed
/// via a 'where' clause.
ArrayRef<Requirement> getTypeAliasRequirements() const;
/// Get the list of protocols appearing on the right hand side of conformance
/// requirements. Computed from the structural requirements, above.
ArrayRef<ProtocolDecl *> getProtocolDependencies() const;