[XL] Change in dart/sdk[main]: DeCo. Use primary initializer scope for field initializers.

0 views
Skip to first unread message

Konstantin Shcheglov (Gerrit)

unread,
Jan 8, 2026, 5:52:39 PM (3 days ago) Jan 8
to Paul Berry, Johnni Winther, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Johnni Winther, Paul Berry and Samuel Rawlins

Konstantin Shcheglov voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Johnni Winther
  • Paul Berry
  • Samuel Rawlins
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: If035464a318262270b05774c2945ce5b073e486d
Gerrit-Change-Number: 471406
Gerrit-PatchSet: 4
Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Johnni Winther <johnni...@google.com>
Gerrit-Comment-Date: Thu, 08 Jan 2026 22:52:34 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy

Paul Berry (Gerrit)

unread,
Jan 8, 2026, 6:54:26 PM (3 days ago) Jan 8
to Konstantin Shcheglov, Johnni Winther, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Johnni Winther, Konstantin Shcheglov and Samuel Rawlins

Paul Berry added 6 comments

File pkg/analyzer/lib/dart/element/element.dart
Line 1940, Patchset 4 (Latest): /// The primary constructor of this element.
Paul Berry . unresolved

Clarify what it means if this getter returns `null`, e.g.:

```suggestion
/// The primary constructor of this element, or `null` if this element has no
/// primary constructor.
```
File pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
Line 327, Patchset 4 (Latest): void nonLateInstanceField_enter({
Paul Berry . unresolved

The name of this method, and its type signature, suggest that it should be called whenever entering a non-late instance field, regardless of whether there are primary constructor parameters. But the call site in `VariableDeclarationResolver.resolve` only calls it if `primaryConstructorParameters` is non-null.

I suggest either:

  • Change the name to something that reflects the fact that the methods purpose is to declare primary constructor parameters (e.g. `declarePrimaryConstructorParameters()`),
  • Make the `primaryConstructorParameters` argument non-nullable,
  • And remove the `if` test on line 330.

Or:

  • Remove the `if` test at the call site (line 63 of `variable_declaration_resolver.dart`) so that this method is always called.
File pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart
Line 48, Patchset 4 (Latest): List<FormalParameterElementImpl>? primaryConstructorParameters;
Paul Berry . unresolved

The name suggests that this value will be non-null whenever there are primary constructor parameters. But the behavior below is that this value will be non-null whenever there are primary constructor parameters *that are in scope*. How about renaming this to `inScopePrimaryConstructorParameters`?

File pkg/analyzer/lib/src/summary2/ast_resolver.dart
Line 115, Patchset 4 (Latest): List<FormalParameterElementImpl>? primaryConstructorParameters,
Paul Berry . unresolved

The name suggests that this value will be non-null whenever there are primary constructor parameters. But the behavior at the call site is that this value will be non-null whenever there are primary constructor parameters *that are in scope*. How about renaming this to `inScopePrimaryConstructorParameters`?

File pkg/analyzer/lib/src/summary2/top_level_inference.dart
Line 78, Patchset 4 (Latest): List<FormalParameterElementImpl>? primaryConstructorParameters;
Paul Berry . unresolved

The name suggests that this value will be non-null whenever there are primary constructor parameters. But the behavior below is that this value will be non-null whenever there are primary constructor parameters *that are in scope*. How about renaming this to `inScopePrimaryConstructorParameters`?

Line 213, Patchset 4 (Latest): List<FormalParameterElementImpl>? primaryConstructorParameters;
Paul Berry . unresolved

The name suggests that this value will be non-null whenever there are primary constructor parameters. But the behavior below is that this value will be non-null whenever there are primary constructor parameters *that are in scope*. How about renaming this to `inScopePrimaryConstructorParameters`?

Open in Gerrit

Related details

Attention is currently required from:
  • Johnni Winther
  • Konstantin Shcheglov
  • Samuel Rawlins
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: If035464a318262270b05774c2945ce5b073e486d
Gerrit-Change-Number: 471406
Gerrit-PatchSet: 4
Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
Gerrit-Attention: Johnni Winther <johnni...@google.com>
Gerrit-Comment-Date: Thu, 08 Jan 2026 23:54:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Konstantin Shcheglov (Gerrit)

unread,
Jan 8, 2026, 7:16:09 PM (3 days ago) Jan 8
to Paul Berry, Johnni Winther, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Johnni Winther, Paul Berry and Samuel Rawlins

Konstantin Shcheglov added 6 comments

File pkg/analyzer/lib/dart/element/element.dart
Line 1940, Patchset 4: /// The primary constructor of this element.
Paul Berry . resolved

Clarify what it means if this getter returns `null`, e.g.:

```suggestion
/// The primary constructor of this element, or `null` if this element has no
/// primary constructor.
```
Konstantin Shcheglov

Done

File pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
Line 327, Patchset 4: void nonLateInstanceField_enter({
Paul Berry . resolved

The name of this method, and its type signature, suggest that it should be called whenever entering a non-late instance field, regardless of whether there are primary constructor parameters. But the call site in `VariableDeclarationResolver.resolve` only calls it if `primaryConstructorParameters` is non-null.

I suggest either:

  • Change the name to something that reflects the fact that the methods purpose is to declare primary constructor parameters (e.g. `declarePrimaryConstructorParameters()`),
  • Make the `primaryConstructorParameters` argument non-nullable,
  • And remove the `if` test on line 330.

Or:

  • Remove the `if` test at the call site (line 63 of `variable_declaration_resolver.dart`) so that this method is always called.
Konstantin Shcheglov

Done

File pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart
Line 48, Patchset 4: List<FormalParameterElementImpl>? primaryConstructorParameters;
Paul Berry . resolved

The name suggests that this value will be non-null whenever there are primary constructor parameters. But the behavior below is that this value will be non-null whenever there are primary constructor parameters *that are in scope*. How about renaming this to `inScopePrimaryConstructorParameters`?

Konstantin Shcheglov

Done

File pkg/analyzer/lib/src/summary2/ast_resolver.dart
Line 115, Patchset 4: List<FormalParameterElementImpl>? primaryConstructorParameters,
Paul Berry . resolved

The name suggests that this value will be non-null whenever there are primary constructor parameters. But the behavior at the call site is that this value will be non-null whenever there are primary constructor parameters *that are in scope*. How about renaming this to `inScopePrimaryConstructorParameters`?

Konstantin Shcheglov

Done

File pkg/analyzer/lib/src/summary2/top_level_inference.dart
Line 78, Patchset 4: List<FormalParameterElementImpl>? primaryConstructorParameters;
Paul Berry . resolved

The name suggests that this value will be non-null whenever there are primary constructor parameters. But the behavior below is that this value will be non-null whenever there are primary constructor parameters *that are in scope*. How about renaming this to `inScopePrimaryConstructorParameters`?

Konstantin Shcheglov

Done

Line 213, Patchset 4: List<FormalParameterElementImpl>? primaryConstructorParameters;
Paul Berry . resolved

The name suggests that this value will be non-null whenever there are primary constructor parameters. But the behavior below is that this value will be non-null whenever there are primary constructor parameters *that are in scope*. How about renaming this to `inScopePrimaryConstructorParameters`?

Konstantin Shcheglov

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Johnni Winther
  • Paul Berry
  • Samuel Rawlins
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: If035464a318262270b05774c2945ce5b073e486d
Gerrit-Change-Number: 471406
Gerrit-PatchSet: 5
Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Johnni Winther <johnni...@google.com>
Gerrit-Comment-Date: Fri, 09 Jan 2026 00:16:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Paul Berry <paul...@google.com>
unsatisfied_requirement
open
diffy

Paul Berry (Gerrit)

unread,
Jan 8, 2026, 8:05:24 PM (3 days ago) Jan 8
to Konstantin Shcheglov, Johnni Winther, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Johnni Winther, Konstantin Shcheglov and Samuel Rawlins

Paul Berry voted and added 1 comment

Votes added by Paul Berry

Code-Review+1

1 comment

Patchset-level comments
Open in Gerrit

Related details

Attention is currently required from:
  • Johnni Winther
  • Konstantin Shcheglov
  • Samuel Rawlins
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: sdk
    Gerrit-Branch: main
    Gerrit-Change-Id: If035464a318262270b05774c2945ce5b073e486d
    Gerrit-Change-Number: 471406
    Gerrit-PatchSet: 5
    Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
    Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
    Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
    Gerrit-Reviewer: Paul Berry <paul...@google.com>
    Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
    Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
    Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
    Gerrit-Attention: Johnni Winther <johnni...@google.com>
    Gerrit-Comment-Date: Fri, 09 Jan 2026 01:05:21 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Samuel Rawlins (Gerrit)

    unread,
    Jan 8, 2026, 10:21:53 PM (3 days ago) Jan 8
    to Konstantin Shcheglov, Paul Berry, Johnni Winther, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
    Attention needed from Johnni Winther and Konstantin Shcheglov

    Samuel Rawlins voted Code-Review+1

    Code-Review+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Johnni Winther
    • Konstantin Shcheglov
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: sdk
    Gerrit-Branch: main
    Gerrit-Change-Id: If035464a318262270b05774c2945ce5b073e486d
    Gerrit-Change-Number: 471406
    Gerrit-PatchSet: 5
    Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
    Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
    Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
    Gerrit-Reviewer: Paul Berry <paul...@google.com>
    Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
    Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
    Gerrit-Attention: Johnni Winther <johnni...@google.com>
    Gerrit-Comment-Date: Fri, 09 Jan 2026 03:21:50 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Konstantin Shcheglov (Gerrit)

    unread,
    Jan 8, 2026, 10:22:37 PM (3 days ago) Jan 8
    to Samuel Rawlins, Paul Berry, Johnni Winther, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
    Attention needed from Johnni Winther

    Konstantin Shcheglov voted Commit-Queue+2

    Commit-Queue+2
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Johnni Winther
    Submit Requirements:
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: sdk
    Gerrit-Branch: main
    Gerrit-Change-Id: If035464a318262270b05774c2945ce5b073e486d
    Gerrit-Change-Number: 471406
    Gerrit-PatchSet: 5
    Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
    Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
    Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
    Gerrit-Reviewer: Paul Berry <paul...@google.com>
    Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
    Gerrit-Attention: Johnni Winther <johnni...@google.com>
    Gerrit-Comment-Date: Fri, 09 Jan 2026 03:22:34 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Commit Queue (Gerrit)

    unread,
    Jan 8, 2026, 10:23:11 PM (3 days ago) Jan 8
    to Konstantin Shcheglov, Samuel Rawlins, Paul Berry, Johnni Winther, dart-analys...@google.com, rev...@dartlang.org

    Commit Queue submitted the change

    Change information

    Commit message:
    DeCo. Use primary initializer scope for field initializers.
    Change-Id: If035464a318262270b05774c2945ce5b073e486d
    Reviewed-by: Samuel Rawlins <sraw...@google.com>
    Commit-Queue: Konstantin Shcheglov <sche...@google.com>
    Reviewed-by: Paul Berry <paul...@google.com>
    Files:
    • M pkg/analyzer/api.txt
    • M pkg/analyzer/lib/dart/element/element.dart
    • M pkg/analyzer/lib/src/dart/element/element.dart
    • M pkg/analyzer/lib/src/dart/resolver/flow_analysis_visitor.dart
    • M pkg/analyzer/lib/src/dart/resolver/variable_declaration_resolver.dart
    • M pkg/analyzer/lib/src/generated/resolver.dart
    • M pkg/analyzer/lib/src/summary2/ast_resolver.dart
    • M pkg/analyzer/lib/src/summary2/reference_resolver.dart
    • M pkg/analyzer/lib/src/summary2/top_level_inference.dart
    • M pkg/analyzer/test/src/dart/resolution/class_test.dart
    • M pkg/analyzer/test/src/dart/resolution/enum_test.dart
    • M pkg/analyzer/test/src/summary/elements/class_test.dart
    • M pkg/analyzer/test/src/summary/elements/enum_test.dart
    Change size: XL
    Delta: 13 files changed, 1446 insertions(+), 30 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Paul Berry, +1 by Samuel Rawlins
    Open in Gerrit
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: merged
    Gerrit-Project: sdk
    Gerrit-Branch: main
    Gerrit-Change-Id: If035464a318262270b05774c2945ce5b073e486d
    Gerrit-Change-Number: 471406
    Gerrit-PatchSet: 6
    Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages