@@ -167,30 +167,20 @@ private extension VariableShadowingRule {
167167 if isShadowingOuterScope ( identifierText) {
168168 violations. append ( identifier. identifier. positionAfterSkippingLeadingTrivia)
169169 }
170- return
171- }
172-
173- // Recurse into tuple patterns: e.g., (a, b)
174- if let tuple = pattern. as ( TuplePatternSyntax . self) {
170+ } else if let tuple = pattern. as ( TuplePatternSyntax . self) {
171+ // Recurse into tuple patterns: e.g., (a, b)
175172 tuple. elements. forEach { element in
176173 checkForShadowing ( in: element. pattern)
177174 }
178- return
179- }
180-
181- // Recurse into value binding patterns: e.g., `let a`, `var (a, b)`
182- if let valueBinding = pattern. as ( ValueBindingPatternSyntax . self) {
175+ } else if let valueBinding = pattern. as ( ValueBindingPatternSyntax . self) {
176+ // Recurse into optional binding patterns: e.g., `if let a`, `while var (a, b)`
183177 checkForShadowing ( in: valueBinding. pattern)
184- return
185178 }
186-
187- // Other pattern kinds are not relevant for shadowing checks here; no action needed.
188179 }
189180
190181 private func isShadowingOuterScope( _ identifier: String ) -> Bool {
191182 guard scope. count > 1 else { return false }
192183
193- // Use early exit and lazy evaluation for better performance
194184 for scopeDeclarations in scope. dropLast ( ) where
195185 scopeDeclarations. contains ( where: { $0. declares ( id: identifier) } ) {
196186 return true
0 commit comments