[dart-lang/sdk] 45ab76: DeCo. Pass LocalScope to ScopeContext.withLocalScope

0 views
Skip to first unread message

Konstantin Scheglov

unread,
11:00 AM (9 hours ago) 11:00 AM
to com...@dartlang.org
Branch: refs/heads/main
Home: https://github.com/dart-lang/sdk
Commit: 45ab768bf571e0186100f147e002d08151fe19dd
https://github.com/dart-lang/sdk/commit/45ab768bf571e0186100f147e002d08151fe19dd
Author: Konstantin Shcheglov <sche...@google.com>
Date: 2026-02-23 (Mon, 23 Feb 2026)

Changed paths:
M pkg/analyzer/lib/src/dart/ast/ast.dart
M pkg/analyzer/lib/src/dart/element/scope.dart
M pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
M pkg/analyzer/lib/src/dart/resolver/for_resolver.dart
M pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart
M pkg/analyzer/lib/src/dart/resolver/scope_context.dart
M pkg/analyzer/lib/src/generated/resolver.dart
M pkg/analyzer/test/src/dart/resolution/for_statement_test.dart
M pkg/analyzer/test/src/dart/resolution/local_function_test.dart
M pkg/analyzer/test/src/dart/resolution/local_variable_test.dart
M pkg/analyzer/test/src/dart/resolution/pattern_assignment_test.dart
M pkg/analyzer/test/src/dart/resolution/pattern_variable_declaration_statement_test.dart

Log Message:
-----------
DeCo. Pass LocalScope to ScopeContext.withLocalScope

Change ScopeContext.withLocalScope to pass the created LocalScope to the
callback, and add LocalScope helpers for bulk insertion of declared
elements.

Refactor resolution/scoping visitors to use the provided LocalScope
rather than downcasting nameScope or relying on ad-hoc predeclaration:
- Predeclare local functions, local variables, and pattern variables in the
correct enclosing scope before visiting initializers/bodies, so lexical
lookup binds to loop/local elements consistently (including in implicit
block scopes for control-flow sub-statements).
- Centralize for-loop-parts handling (declarations, identifiers, patterns)
so each part is visited in the required order while installing the right
loop-local bindings.
- Compute and store declared pattern-variable elements directly on the
relevant AST nodes, and update ForEachPartsWithPattern to carry variable
elements (so flow analysis can declare them without extra indirection).

Also ensure metadata on pattern variable declarations and pattern-for
parts is visited in the same scope model as other declarations.

Change-Id: I35d52860b6816196085d79979cda861583c850be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482540
Reviewed-by: Johnni Winther <johnni...@google.com>


Commit: 7f32691a95b5e34aa7e8157e6f57c3e4b010460b
https://github.com/dart-lang/sdk/commit/7f32691a95b5e34aa7e8157e6f57c3e4b010460b
Author: Konstantin Shcheglov <sche...@google.com>
Date: 2026-02-23 (Mon, 23 Feb 2026)

Changed paths:
M pkg/analyzer/lib/src/generated/error_verifier.dart

Log Message:
-----------
CQ. Make ErrorVerifier._featureSet non-nullable.

Change-Id: I14db847fda69f6fd690b02290d71600e237d2373
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482700
Reviewed-by: Johnni Winther <johnni...@google.com>


Compare: https://github.com/dart-lang/sdk/compare/2a375317f4bc...7f32691a95b5

To unsubscribe from these emails, change your notification settings at https://github.com/dart-lang/sdk/settings/notifications
Reply all
Reply to author
Forward
0 new messages