Skip to content

Commit 27f8f72

Browse files
committed
AST: Tailored circularity diagnostic for StructuralTypeRequest
1 parent 30e2945 commit 27f8f72

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/swift/AST/TypeCheckRequests.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ class StructuralTypeRequest :
874874
public:
875875
// Caching.
876876
bool isCached() const { return true; }
877+
void diagnoseCycle(DiagnosticEngine &diags) const;
877878
};
878879

879880
/// Request the fragile function kind for the context.

lib/AST/TypeCheckRequests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,17 @@ void UnderlyingTypeRequest::diagnoseCycle(DiagnosticEngine &diags) const {
819819
aliasDecl->getName());
820820
}
821821

822+
//----------------------------------------------------------------------------//
823+
// StructuralTypeRequest computation.
824+
//----------------------------------------------------------------------------//
825+
826+
void StructuralTypeRequest::diagnoseCycle(DiagnosticEngine &diags) const {
827+
auto aliasDecl = std::get<0>(getStorage());
828+
diags.diagnose(aliasDecl, diag::recursive_decl_reference,
829+
aliasDecl->getDescriptiveKind(),
830+
aliasDecl->getName());
831+
}
832+
822833
//----------------------------------------------------------------------------//
823834
// EnumRawValuesRequest computation.
824835
//----------------------------------------------------------------------------//

0 commit comments

Comments
 (0)