mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Compute the requirement signature before visiting protocol members
This commit is contained in:
@@ -2650,6 +2650,12 @@ public:
|
|||||||
|
|
||||||
TypeChecker::checkDeclAttributes(PD);
|
TypeChecker::checkDeclAttributes(PD);
|
||||||
|
|
||||||
|
// Explicity compute the requirement signature to detect errors.
|
||||||
|
// Do this before visiting members, to avoid a request cycle if
|
||||||
|
// a member referenecs another declaration whose generic signature
|
||||||
|
// has a conformance requirement to this protocol.
|
||||||
|
auto reqSig = PD->getRequirementSignature().getRequirements();
|
||||||
|
|
||||||
// Check the members.
|
// Check the members.
|
||||||
for (auto Member : PD->getMembers())
|
for (auto Member : PD->getMembers())
|
||||||
visit(Member);
|
visit(Member);
|
||||||
@@ -2663,9 +2669,6 @@ public:
|
|||||||
if (!SF || SF->Kind != SourceFileKind::Interface)
|
if (!SF || SF->Kind != SourceFileKind::Interface)
|
||||||
TypeChecker::inferDefaultWitnesses(PD);
|
TypeChecker::inferDefaultWitnesses(PD);
|
||||||
|
|
||||||
// Explicity compute the requirement signature to detect errors.
|
|
||||||
auto reqSig = PD->getRequirementSignature().getRequirements();
|
|
||||||
|
|
||||||
if (PD->getASTContext().TypeCheckerOpts.DebugGenericSignatures) {
|
if (PD->getASTContext().TypeCheckerOpts.DebugGenericSignatures) {
|
||||||
auto requirementsSig =
|
auto requirementsSig =
|
||||||
GenericSignature::get({PD->getProtocolSelfType()}, reqSig);
|
GenericSignature::get({PD->getProtocolSelfType()}, reqSig);
|
||||||
|
|||||||
18
test/Generics/protocol_typealias_cycle_1a.swift
Normal file
18
test/Generics/protocol_typealias_cycle_1a.swift
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// RUN: %target-typecheck-verify-swift
|
||||||
|
|
||||||
|
protocol P {
|
||||||
|
associatedtype X
|
||||||
|
associatedtype Y where Y : Q
|
||||||
|
}
|
||||||
|
|
||||||
|
protocol Q {
|
||||||
|
associatedtype T
|
||||||
|
}
|
||||||
|
|
||||||
|
struct S: Q {
|
||||||
|
typealias T = Int
|
||||||
|
}
|
||||||
|
|
||||||
|
extension P where X == () {
|
||||||
|
typealias Y = S
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user