Skip to content

Commit 5dc1295

Browse files
committed
[Type refinement context] Don't query property wrappers just for range info
Querying property wrappers involves semantic analysis that can cause cyclic references while building the type refinement context, and it's unnecessary: we need only know that these are custom attributes to incorporate their source ranges. Switch to the simpler/cheaper query. A small part of fixing the cyclic references in rdar://112079160.
1 parent 16c59fa commit 5dc1295

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,16 @@ class TypeRefinementContextBuilder : private ASTWalker {
679679
// For a variable declaration (without accessors) we use the range of the
680680
// containing pattern binding declaration to make sure that we include
681681
// any type annotation in the type refinement context range. We also
682-
// need to include any attached property wrappers.
682+
// need to include any custom attributes that were written on the
683+
// declaration.
683684
if (auto *varDecl = dyn_cast<VarDecl>(storageDecl)) {
684685
if (auto *PBD = varDecl->getParentPatternBinding())
685686
Range = PBD->getSourceRange();
686687

687-
for (auto *propertyWrapper : varDecl->getAttachedPropertyWrappers()) {
688-
Range.widen(propertyWrapper->getRange());
688+
for (auto attr : varDecl->getOriginalAttrs()) {
689+
if (auto customAttr = dyn_cast<CustomAttr>(attr)) {
690+
Range.widen(customAttr->getRange());
691+
}
689692
}
690693
}
691694

@@ -696,7 +699,7 @@ class TypeRefinementContextBuilder : private ASTWalker {
696699
// locations and have callers of that method provide appropriate source
697700
// locations.
698701
SourceRange BracesRange = storageDecl->getBracesRange();
699-
if (storageDecl->hasParsedAccessors() && BracesRange.isValid()) {
702+
if (BracesRange.isValid()) {
700703
Range.widen(BracesRange);
701704
}
702705

0 commit comments

Comments
 (0)