@@ -701,23 +701,23 @@ class NodeAdder
701
701
if (auto *var = patternBinding->getSingleVar ())
702
702
scopeCreator.addChildrenForKnownAttributes (var, parentScope);
703
703
704
- const bool isLocalBinding = patternBinding->getDeclContext ()->isLocalContext ();
705
-
706
- const DeclVisibilityKind vis =
707
- isLocalBinding ? DeclVisibilityKind::LocalVariable
708
- : DeclVisibilityKind::MemberOfCurrentNominal;
709
704
auto *insertionPoint = parentScope;
710
705
for (auto i : range (patternBinding->getNumPatternEntries ())) {
706
+ bool isLocalBinding = false ;
707
+ if (auto *varDecl = patternBinding->getAnchoringVarDecl (i)) {
708
+ isLocalBinding = varDecl->getDeclContext ()->isLocalContext ();
709
+ }
710
+
711
711
insertionPoint =
712
712
scopeCreator
713
713
.ifUniqueConstructExpandAndInsert <PatternEntryDeclScope>(
714
- insertionPoint, patternBinding, i, vis )
714
+ insertionPoint, patternBinding, i, isLocalBinding )
715
715
.getPtrOr (insertionPoint);
716
- }
717
716
718
- ASTScopeAssert (isLocalBinding || insertionPoint == parentScope,
719
- " Bindings at the top-level or members of types should "
720
- " not change the insertion point" );
717
+ ASTScopeAssert (isLocalBinding || insertionPoint == parentScope,
718
+ " Bindings at the top-level or members of types should "
719
+ " not change the insertion point" );
720
+ }
721
721
722
722
return insertionPoint;
723
723
}
@@ -991,7 +991,7 @@ PatternEntryDeclScope::expandAScopeThatCreatesANewInsertionPoint(
991
991
" Original inits are always after the '='" );
992
992
scopeCreator
993
993
.constructExpandAndInsertUncheckable <PatternEntryInitializerScope>(
994
- this , decl, patternEntryIndex, vis );
994
+ this , decl, patternEntryIndex, isLocalBinding );
995
995
}
996
996
997
997
// Add accessors for the variables in this pattern.
@@ -1002,7 +1002,7 @@ PatternEntryDeclScope::expandAScopeThatCreatesANewInsertionPoint(
1002
1002
// In local context, the PatternEntryDeclScope becomes the insertion point, so
1003
1003
// that all any bindings introduecd by the pattern are in scope for subsequent
1004
1004
// lookups.
1005
- if (vis == DeclVisibilityKind::LocalVariable )
1005
+ if (isLocalBinding )
1006
1006
return {this , " All code that follows is inside this scope" };
1007
1007
1008
1008
return {getParent ().get (), " Global and type members do not introduce scopes" };
@@ -1378,8 +1378,9 @@ ASTScopeImpl *LabeledConditionalStmtScope::createNestedConditionalClauseScopes(
1378
1378
1379
1379
AbstractPatternEntryScope::AbstractPatternEntryScope (
1380
1380
PatternBindingDecl *declBeingScoped, unsigned entryIndex,
1381
- DeclVisibilityKind vis)
1382
- : decl(declBeingScoped), patternEntryIndex(entryIndex), vis(vis) {
1381
+ bool isLocalBinding)
1382
+ : decl(declBeingScoped), patternEntryIndex(entryIndex),
1383
+ isLocalBinding(isLocalBinding) {
1383
1384
ASTScopeAssert (entryIndex < declBeingScoped->getPatternList ().size (),
1384
1385
" out of bounds" );
1385
1386
}
0 commit comments