[M] Change in dart/sdk[main]: [model] Handle local function instantiations in type checks

0 views
Skip to first unread message

Chloe Stefantsova (Gerrit)

unread,
Aug 29, 2025, 7:18:17 AMAug 29
to Chloe Stefantsova, Johnni Winther, Paul Berry, Erik Ernst, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Erik Ernst, Johnni Winther and Paul Berry

Chloe Stefantsova voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Erik Ernst
  • Johnni Winther
  • Paul Berry
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: I6007bafaf7058bf1b2d5f7ec28f1413bc5a4e694
Gerrit-Change-Number: 447700
Gerrit-PatchSet: 3
Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
Gerrit-Reviewer: Erik Ernst <eer...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Reviewer: Paul Berry <paul...@google.com>
Gerrit-Attention: Johnni Winther <johnni...@google.com>
Gerrit-Attention: Erik Ernst <eer...@google.com>
Gerrit-Attention: Paul Berry <paul...@google.com>
Gerrit-Comment-Date: Fri, 29 Aug 2025 11:18:12 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy

Johnni Winther (Gerrit)

unread,
Aug 29, 2025, 7:36:09 AMAug 29
to Chloe Stefantsova, Paul Berry, Erik Ernst, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Chloe Stefantsova, Erik Ernst and Paul Berry

Johnni Winther voted and added 2 comments

Votes added by Johnni Winther

Code-Review+1

2 comments

File tests/language/inference/issue_61370_2_error_test.dart
Line 17, Patchset 3 (Latest): g.m<F<Iterable<int?> Function()>>(); // No error, OK.
Johnni Winther . unresolved

Remove these comments.

File tests/language/inference/issue_61370_error_test.dart
Line 17, Patchset 3 (Latest): g.m<F<int? Function()>>(); // No error, OK.
Johnni Winther . unresolved

Remove these comments.

Open in Gerrit

Related details

Attention is currently required from:
  • Chloe Stefantsova
  • Erik Ernst
  • Paul Berry
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: I6007bafaf7058bf1b2d5f7ec28f1413bc5a4e694
    Gerrit-Change-Number: 447700
    Gerrit-PatchSet: 3
    Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Erik Ernst <eer...@google.com>
    Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
    Gerrit-Reviewer: Paul Berry <paul...@google.com>
    Gerrit-Attention: Erik Ernst <eer...@google.com>
    Gerrit-Attention: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Attention: Paul Berry <paul...@google.com>
    Gerrit-Comment-Date: Fri, 29 Aug 2025 11:36:04 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Chloe Stefantsova (Gerrit)

    unread,
    Aug 29, 2025, 7:41:46 AMAug 29
    to Chloe Stefantsova, Johnni Winther, Paul Berry, Erik Ernst, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
    Attention needed from Erik Ernst and Paul Berry

    Chloe Stefantsova added 3 comments

    Patchset-level comments
    File-level comment, Patchset 4 (Latest):
    Chloe Stefantsova . resolved

    Thanks for the review and the suggestions, Johnni. I've updated the CL accordingly.

    File tests/language/inference/issue_61370_2_error_test.dart
    Line 17, Patchset 3: g.m<F<Iterable<int?> Function()>>(); // No error, OK.
    Johnni Winther . resolved

    Remove these comments.

    Chloe Stefantsova

    Done

    File tests/language/inference/issue_61370_error_test.dart
    Line 17, Patchset 3: g.m<F<int? Function()>>(); // No error, OK.
    Johnni Winther . resolved

    Remove these comments.

    Chloe Stefantsova

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Erik Ernst
    • Paul Berry
    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: I6007bafaf7058bf1b2d5f7ec28f1413bc5a4e694
    Gerrit-Change-Number: 447700
    Gerrit-PatchSet: 4
    Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Erik Ernst <eer...@google.com>
    Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
    Gerrit-Reviewer: Paul Berry <paul...@google.com>
    Gerrit-Attention: Erik Ernst <eer...@google.com>
    Gerrit-Attention: Paul Berry <paul...@google.com>
    Gerrit-Comment-Date: Fri, 29 Aug 2025 11:41:39 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Johnni Winther <johnni...@google.com>
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Erik Ernst (Gerrit)

    unread,
    Aug 29, 2025, 9:20:10 AMAug 29
    to Chloe Stefantsova, Johnni Winther, Paul Berry, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
    Attention needed from Chloe Stefantsova and Paul Berry

    Erik Ernst voted and added 2 comments

    Votes added by Erik Ernst

    Code-Review+1

    2 comments

    Patchset-level comments
    Erik Ernst . resolved

    LGTM

    File pkg/analyzer/lib/src/dart/resolver/function_reference_resolver.dart
    Line 974, Patchset 4 (Latest): }
    Erik Ernst . unresolved

    Tempting to suggest:

    ```
    extension on Element {
    DartType? get referenceType {
    final self = this;
    return switch (self) {
    ConstructorElement() => self.type,
    TopLevelFunctionElement() => self.type,
    LocalFunctionElement() => self.type,
    PropertyAccessorElement() => self.returnType,
    MethodElement() => self.type,
    VariableElement() => self.type,
    _ => null,
    };
    }
    }
    ```
    or `T1() || T2() || ... => self.type` if the types match up.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Chloe Stefantsova
    • Paul Berry
    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: I6007bafaf7058bf1b2d5f7ec28f1413bc5a4e694
    Gerrit-Change-Number: 447700
    Gerrit-PatchSet: 4
    Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Erik Ernst <eer...@google.com>
    Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
    Gerrit-Reviewer: Paul Berry <paul...@google.com>
    Gerrit-Attention: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Attention: Paul Berry <paul...@google.com>
    Gerrit-Comment-Date: Fri, 29 Aug 2025 13:20:05 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy

    Paul Berry (Gerrit)

    unread,
    Aug 29, 2025, 4:51:06 PMAug 29
    to Chloe Stefantsova, Erik Ernst, Johnni Winther, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
    Attention needed from Chloe Stefantsova

    Paul Berry voted and added 2 comments

    Votes added by Paul Berry

    Code-Review+1

    2 comments

    Patchset-level comments
    Paul Berry . resolved

    lgtm

    File pkg/analyzer/lib/src/dart/resolver/function_reference_resolver.dart
    Erik Ernst . unresolved

    Tempting to suggest:

    ```
    extension on Element {
    DartType? get referenceType {
    final self = this;
    return switch (self) {
    ConstructorElement() => self.type,
    TopLevelFunctionElement() => self.type,
    LocalFunctionElement() => self.type,
    PropertyAccessorElement() => self.returnType,
    MethodElement() => self.type,
    VariableElement() => self.type,
    _ => null,
    };
    }
    }
    ```
    or `T1() || T2() || ... => self.type` if the types match up.
    Paul Berry

    I don't think `T1() || T2() || ... => self.type` works, but `T1(:var type) || T2(:var type) || ... => type` probably does.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Chloe Stefantsova
    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: I6007bafaf7058bf1b2d5f7ec28f1413bc5a4e694
    Gerrit-Change-Number: 447700
    Gerrit-PatchSet: 4
    Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Erik Ernst <eer...@google.com>
    Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
    Gerrit-Reviewer: Paul Berry <paul...@google.com>
    Gerrit-Attention: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Comment-Date: Fri, 29 Aug 2025 20:51:04 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Erik Ernst <eer...@google.com>
    satisfied_requirement
    open
    diffy

    Chloe Stefantsova (Gerrit)

    unread,
    Sep 1, 2025, 3:35:50 AMSep 1
    to Chloe Stefantsova, Paul Berry, Erik Ernst, Johnni Winther, Commit Queue, dart-analys...@google.com, rev...@dartlang.org

    Chloe Stefantsova voted and added 2 comments

    Votes added by Chloe Stefantsova

    Commit-Queue+2

    2 comments

    Patchset-level comments
    File-level comment, Patchset 5 (Latest):
    Chloe Stefantsova . resolved

    Thank you Erik and Paul for taking a look and for the suggestions. I've updated the CL accordingly.

    File pkg/analyzer/lib/src/dart/resolver/function_reference_resolver.dart
    Line 974, Patchset 4: }
    Erik Ernst . resolved

    Tempting to suggest:

    ```
    extension on Element {
    DartType? get referenceType {
    final self = this;
    return switch (self) {
    ConstructorElement() => self.type,
    TopLevelFunctionElement() => self.type,
    LocalFunctionElement() => self.type,
    PropertyAccessorElement() => self.returnType,
    MethodElement() => self.type,
    VariableElement() => self.type,
    _ => null,
    };
    }
    }
    ```
    or `T1() || T2() || ... => self.type` if the types match up.
    Paul Berry

    I don't think `T1() || T2() || ... => self.type` works, but `T1(:var type) || T2(:var type) || ... => type` probably does.

    Chloe Stefantsova

    Thank you both for the suggestions. I went forward with the option based on the `switch` expression, since the `type` getters don't align on the type perfectly, and I had to use `DartType` in the patterns instead of `var`, which is too wordy IMO.

    Open in Gerrit

    Related details

    Attention set is empty
    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: I6007bafaf7058bf1b2d5f7ec28f1413bc5a4e694
    Gerrit-Change-Number: 447700
    Gerrit-PatchSet: 5
    Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Erik Ernst <eer...@google.com>
    Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
    Gerrit-Reviewer: Paul Berry <paul...@google.com>
    Gerrit-Comment-Date: Mon, 01 Sep 2025 07:35:45 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Erik Ernst <eer...@google.com>
    Comment-In-Reply-To: Paul Berry <paul...@google.com>
    satisfied_requirement
    open
    diffy

    Commit Queue (Gerrit)

    unread,
    Sep 1, 2025, 4:11:18 AMSep 1
    to Chloe Stefantsova, Paul Berry, Erik Ernst, Johnni Winther, dart-analys...@google.com, rev...@dartlang.org

    Commit Queue submitted the change with unreviewed changes

    Unreviewed changes

    4 is the latest approved patch-set.
    The change was submitted with unreviewed changes in the following files:

    ```
    The name of the file: pkg/analyzer/lib/src/dart/resolver/function_reference_resolver.dart
    Insertions: 10, Deletions: 15.

    The diff is too large to show. Please review the diff.
    ```

    Change information

    Commit message:
    [model] Handle local function instantiations in type checks

    Closes https://github.com/dart-lang/sdk/issues/61370
    Change-Id: I6007bafaf7058bf1b2d5f7ec28f1413bc5a4e694
    Reviewed-by: Erik Ernst <eer...@google.com>
    Reviewed-by: Paul Berry <paul...@google.com>
    Reviewed-by: Johnni Winther <johnni...@google.com>
    Commit-Queue: Chloe Stefantsova <cstefa...@google.com>
    Files:
    • M pkg/analyzer/lib/src/dart/resolver/function_reference_resolver.dart
    • A tests/language/inference/issue_61370_2_error_test.dart
    • A tests/language/inference/issue_61370_error_test.dart
    Change size: M
    Delta: 3 files changed, 98 insertions(+), 13 deletions(-)
    Branch: refs/heads/main
    Submit Requirements:
    • requirement satisfiedCode-Review: +1 by Erik Ernst, +1 by Paul Berry, +1 by Johnni Winther
    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: I6007bafaf7058bf1b2d5f7ec28f1413bc5a4e694
    Gerrit-Change-Number: 447700
    Gerrit-PatchSet: 6
    Gerrit-Owner: Chloe Stefantsova <cstefa...@google.com>
    Gerrit-Reviewer: Chloe Stefantsova <cstefa...@google.com>
    open
    diffy
    satisfied_requirement
    Reply all
    Reply to author
    Forward
    0 new messages