getInheritedProtocols() skips type resolution and directly resolves
TypeReprs to TypeDecls.
On the other hand, when building a protocol requirement signature,
we use type resolution to resolve inheritance clause entries so
that we can properly support parameterized protocol types, and
protocol compositions that contain classes.
Since a TypeRepr with an invalid sub-component resolves to an
ErrorType, this meant that in invalid code, the first list of
protocols might contain protocols that don't appear in the second.
This broke rewrite system invariants. Fix this by checking if
type resolution failed when building the requirement signature of
a protocol, and if so, also look at getInheritedProtocols().
Fixes https://github.com/apple/swift/issues/61020.
RequirementSignatureRequest
=> TypeAliasRequirementsRequest
=> isConstrainedExtension()
=> GenericSignatureRequest
=> RequirementSignatureRequest
Instead, use getTrailingWhereClause() as an approximation of
isConstrainedExtension().
Fixes rdar://problem/97236936.
Every protocol gets an 'identity conformance' rule [P].[P] => [P].
A trivially-stated circularity is always redundant because of this
rule, and we diagnose circular inheritance elsewhere as a hard
error, so just add a special case to skip adding such a rule here
to avoid the useless warning on top of the existing error.
We want to allow this for all conformance requirements written in protocols
or the `where` clause of protocol extensions.
Fixes rdar://problem/91304291.
A protocol typealias 'typealias T = X' introduces a same-type requirement
'Self.T == Self.X'. However the right hand side of the requirement was
wrapped in a sugared TypeAliasType.
This meant if the requirement surfaced in a redundancy diagnostic, it
would print as 'Self.T == Self.T'. It could also trigger a request cycle
via isInterestingTypealias() in DiagnosticEngine.cpp.
All the pieces are now in place so that the RuleBuilder can assemble
a confluent rewrite system for downstream protocol dependencies,
instead of building rules from protocol requirement signatures.
If you have something like
protocol P {
typealias A = C
associatedtype T : A
}
class C {}
Then ::Structural resolution of 'A' in the inheritance clause will
produce a DependentMemberType 'Self.A'. Check for this case and
attempt ::Interface resolution to get the correct underlying type.
Fixes rdar://problem/90219229.
macine flags to callers.
Callers gate this decision on different flags; InferredGenericSignatureRequestRQM
needs RequirementMachineInferredSignatures to be enabled, and the other
callsites need RequirementMachineProtocolSignatures to be enabled.