[L] Change in dart/sdk[main]: [DAS] Fixes Create setters, getters and fields for using type parameters

0 views
Skip to first unread message

Felipe Morschel (Gerrit)

unread,
Jul 25, 2025, 10:35:01 AMJul 25
to dart-analys...@google.com, rev...@dartlang.org

Felipe Morschel has uploaded the change for review

Commit message

[DAS] Fixes Create setters, getters and fields for using type parameters
Change-Id: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba

Change information

Files:
  • M pkg/analysis_server/lib/src/services/correction/dart/create_field.dart
  • M pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart
  • M pkg/analysis_server/lib/src/services/correction/dart/create_setter.dart
  • M pkg/analysis_server/lib/src/services/correction/fix_internal.dart
  • M pkg/analysis_server/test/src/services/correction/fix/create_field_test.dart
  • M pkg/analysis_server/test/src/services/correction/fix/create_getter_test.dart
  • M pkg/analysis_server/test/src/services/correction/fix/create_setter_test.dart
  • M pkg/analysis_server_plugin/lib/edit/dart/correction_producer.dart
  • A pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
  • M pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
  • M pkg/analyzer_plugin/lib/utilities/change_builder/change_builder_dart.dart
Change size: L
Delta: 11 files changed, 603 insertions(+), 67 deletions(-)
Open in Gerrit

Related details

Attention set is empty
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: newchange
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 1
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Jul 25, 2025, 10:40:07 AMJul 25
to Brian Wilkerson, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Samuel Rawlins

Felipe Morschel added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Felipe Morschel . resolved

This is only part of https://dart-review.googlesource.com/c/sdk/+/442240. The change was becomming way too big for a single CL so this is the start it. Once this lands I have some other stashed changes to rebase and upload on new CLs.

Once I get your approval I'll add someone from the analyzer team to review the newly added file with the extension methods. I'm still not convinced that the naming there is the best I could get but the tests are now passing.

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 1
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Comment-Date: Fri, 25 Jul 2025 14:40:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Jul 25, 2025, 12:28:33 PMJul 25
to Felipe Morschel, Brian Wilkerson, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel and Samuel Rawlins

Brian Wilkerson added 8 comments

Patchset-level comments
Brian Wilkerson . resolved

I haven't checked everything yet, but I thought there were enough comments that I should let you start working on them.

File pkg/analysis_server/test/src/services/correction/fix/create_field_test.dart
Line 250, Patchset 1 (Latest): dynamic field;
Brian Wilkerson . unresolved

I believe that the implicit bound of a type parameter is `Object?`, so we should consider using that here rather than `dynamic`.

File pkg/analysis_server_plugin/lib/edit/dart/correction_producer.dart
Line 696, Patchset 1 (Latest): if (expression.enclosingExecutableElement
Brian Wilkerson . unresolved

Executable elements are not closures. We might need to change the name of this method to reflect the new semantics.

File pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
Line 15, Patchset 1 (Latest): TypeParameterType? isBoundTo(DartType? other) {
Brian Wilkerson . unresolved

I'm not sure what this method is trying to do. Could you provide documentation, and maybe a name that doesn't start with 'is' (because that makes me think it should return a `bool`.

Line 57, Patchset 1 (Latest): DartType? thisOrBound(bool useThis) {
Brian Wilkerson . unresolved

I'm not sure I understand the purpose of this parameter. It looks to me like the method is returning the receiver unless the receiver is a type parameter that isn't in scope. But if [useThis] is `true`, then this method should not have been invoked because the receiver is already known to be a type parameter that is in scope.

And if we already know before we invoke this method whether the receiver is a type parameter, this method just duplicates a check we've already made.

(It might have made more sense if there'd been a doc comment.)

Line 61, Patchset 1 (Latest): return bound;
Brian Wilkerson . unresolved

This isn't valid. The bound of a type parameter can be another type parameter. We really need to iterate until we get to a bound that isn't a type parameter. (Or until we get to a type parameter that we've already seen, because in invalid code we could have an infinite loop if we don't check for that case.

File pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
Line 186, Patchset 1 (Latest): bool alwaysWriteType = false,
Brian Wilkerson . unresolved

In all of the call sites I can find, this value is always computed the same way (by checking for a lint enablement). I'd prefer to remove this parameter and to have the change builder automatically do the right thing by checking the lint's enablement.

Line 187, Patchset 1 (Latest): ExecutableElement? methodBeingCopied,
Brian Wilkerson . unresolved

It took me a while to figure out what's going on here. In part, at least, because I was thrown by the name.

What the method `writeType` really needs is a way to determine, given a `type` that is either a type parameter or is a parameterized type with a type parameter somewhere inside the type arguments, whether that type parameter is in scope where the type is to be written.

The original use case was copying a method, and by passing in the method being copied `writeType` could determine whether a type parameter that was used in the `type` was going to be in scope because it would be defined by the newly created method. That's the only case it handled, and that's not the case you need here.

What we need is to re-write `writeType` to have a more general way of answering the question of whether a type parameter is in scope. For the old use case we can just pass in the type parameters defined by the original method (instead of passing in the whole method). In the case of creating a new member declaration we need to pass in the type parameters of the class (or class-like declaration) to which the declaration is being added.

Unfortunately, `writeType` is a public API, so we'll need to deprecate the old `methodBeingCopied` parameter and add a new parameter (`typeParametersInScope`?) and support both for some hopefully short period of time.

Maybe we could make that be a separate CL (I expect that there are lots of uses of `writeType` that will need to be cleaned up.)

Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
  • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 1
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Fri, 25 Jul 2025 16:28:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Sep 2, 2025, 12:53:51 AMSep 2
to Brian Wilkerson, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org

Felipe Morschel voted and added 1 comment

Votes added by Felipe Morschel

Auto-Submit+1

1 comment

File pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
Line 187, Patchset 1: ExecutableElement? methodBeingCopied,
Brian Wilkerson . resolved

It took me a while to figure out what's going on here. In part, at least, because I was thrown by the name.

What the method `writeType` really needs is a way to determine, given a `type` that is either a type parameter or is a parameterized type with a type parameter somewhere inside the type arguments, whether that type parameter is in scope where the type is to be written.

The original use case was copying a method, and by passing in the method being copied `writeType` could determine whether a type parameter that was used in the `type` was going to be in scope because it would be defined by the newly created method. That's the only case it handled, and that's not the case you need here.

What we need is to re-write `writeType` to have a more general way of answering the question of whether a type parameter is in scope. For the old use case we can just pass in the type parameters defined by the original method (instead of passing in the whole method). In the case of creating a new member declaration we need to pass in the type parameters of the class (or class-like declaration) to which the declaration is being added.

Unfortunately, `writeType` is a public API, so we'll need to deprecate the old `methodBeingCopied` parameter and add a new parameter (`typeParametersInScope`?) and support both for some hopefully short period of time.

Maybe we could make that be a separate CL (I expect that there are lots of uses of `writeType` that will need to be cleaned up.)

Open in Gerrit

Related details

Attention set is empty
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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 2
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Tue, 02 Sep 2025 04:53:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Sep 2, 2025, 11:17:56 AMSep 2
to Brian Wilkerson, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Samuel Rawlins

Felipe Morschel voted and added 7 comments

Votes added by Felipe Morschel

Auto-Submit+1

7 comments

File pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart
Line 127, Patchset 2: bound.ifTypeOrNull<TypeParameterType>()?.element.wrapInList(),
Felipe Morschel . unresolved

I dislike this. I want to replace this expression with a null-aware-element list. I'll rebase this and refactor (here and for field) once the version bump happens.

Do you plan on making the version-bump change @sraw...@google.com?

File pkg/analysis_server/test/src/services/correction/fix/create_field_test.dart
Line 250, Patchset 1: dynamic field;
Brian Wilkerson . resolved

I believe that the implicit bound of a type parameter is `Object?`, so we should consider using that here rather than `dynamic`.

Felipe Morschel

Handled internally by `DartEditBuilderImpl` now. Thanks!

File pkg/analysis_server_plugin/lib/edit/dart/correction_producer.dart
Line 696, Patchset 1: if (expression.enclosingExecutableElement
Brian Wilkerson . resolved

Executable elements are not closures. We might need to change the name of this method to reflect the new semantics.

Felipe Morschel

Thanks for noting!

File pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
Line 15, Patchset 1: TypeParameterType? isBoundTo(DartType? other) {
Brian Wilkerson . resolved

I'm not sure what this method is trying to do. Could you provide documentation, and maybe a name that doesn't start with 'is' (because that makes me think it should return a `bool`.

Felipe Morschel

I think this is better now, please let me know if you still think it could be better. Thanks!

Line 57, Patchset 1: DartType? thisOrBound(bool useThis) {
Brian Wilkerson . resolved

I'm not sure I understand the purpose of this parameter. It looks to me like the method is returning the receiver unless the receiver is a type parameter that isn't in scope. But if [useThis] is `true`, then this method should not have been invoked because the receiver is already known to be a type parameter that is in scope.

And if we already know before we invoke this method whether the receiver is a type parameter, this method just duplicates a check we've already made.

(It might have made more sense if there'd been a doc comment.)

Felipe Morschel

I've done some refactoring after that other CL and this method is not needed anymore so I'll skip these comments. If you still find inconsistencies, please let me know!

Line 61, Patchset 1: return bound;
Brian Wilkerson . resolved

This isn't valid. The bound of a type parameter can be another type parameter. We really need to iterate until we get to a bound that isn't a type parameter. (Or until we get to a type parameter that we've already seen, because in invalid code we could have an infinite loop if we don't check for that case.

File pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
Line 186, Patchset 1: bool alwaysWriteType = false,
Brian Wilkerson . resolved

In all of the call sites I can find, this value is always computed the same way (by checking for a lint enablement). I'd prefer to remove this parameter and to have the change builder automatically do the right thing by checking the lint's enablement.

Felipe Morschel

Great idea!

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 2
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Comment-Date: Tue, 02 Sep 2025 15:17:50 +0000
unsatisfied_requirement
open
diffy

Samuel Rawlins (Gerrit)

unread,
Sep 2, 2025, 11:36:05 AMSep 2
to Felipe Morschel, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Felipe Morschel

Samuel Rawlins added 1 comment

File pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart
Line 127, Patchset 2: bound.ifTypeOrNull<TypeParameterType>()?.element.wrapInList(),
Felipe Morschel . unresolved

I dislike this. I want to replace this expression with a null-aware-element list. I'll rebase this and refactor (here and for field) once the version bump happens.

Do you plan on making the version-bump change @sraw...@google.com?

Samuel Rawlins

I do plan on making this soon. Maybe today.

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Felipe Morschel
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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 3
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Comment-Date: Tue, 02 Sep 2025 15:35:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Sep 3, 2025, 4:16:17 PMSep 3
to Brian Wilkerson, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Samuel Rawlins

Felipe Morschel voted and added 2 comments

Votes added by Felipe Morschel

Auto-Submit+1

2 comments

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Felipe Morschel . resolved

Can I get new reviews for this please? Thanks a lot!

File pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart
Line 127, Patchset 2: bound.ifTypeOrNull<TypeParameterType>()?.element.wrapInList(),
Felipe Morschel . resolved

I dislike this. I want to replace this expression with a null-aware-element list. I'll rebase this and refactor (here and for field) once the version bump happens.

Do you plan on making the version-bump change @sraw...@google.com?

Samuel Rawlins

I do plan on making this soon. Maybe today.

Felipe Morschel

Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 4
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Comment-Date: Wed, 03 Sep 2025 20:16:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
unsatisfied_requirement
open
diffy

Samuel Rawlins (Gerrit)

unread,
Sep 3, 2025, 5:05:46 PMSep 3
to Felipe Morschel, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Felipe Morschel

Samuel Rawlins added 1 comment

File pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart
Line 127, Patchset 2: bound.ifTypeOrNull<TypeParameterType>()?.element.wrapInList(),
Felipe Morschel . resolved

I dislike this. I want to replace this expression with a null-aware-element list. I'll rebase this and refactor (here and for field) once the version bump happens.

Do you plan on making the version-bump change @sraw...@google.com?

Samuel Rawlins

I do plan on making this soon. Maybe today.

Felipe Morschel

Thanks!

Samuel Rawlins

This is done.

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Felipe Morschel
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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 4
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Comment-Date: Wed, 03 Sep 2025 21:05:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Sep 3, 2025, 5:08:15 PMSep 3
to Brian Wilkerson, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Samuel Rawlins

Felipe Morschel added 1 comment

File pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart
Line 127, Patchset 2: bound.ifTypeOrNull<TypeParameterType>()?.element.wrapInList(),
Felipe Morschel . resolved

I dislike this. I want to replace this expression with a null-aware-element list. I'll rebase this and refactor (here and for field) once the version bump happens.

Do you plan on making the version-bump change @sraw...@google.com?

Samuel Rawlins

I do plan on making this soon. Maybe today.

Felipe Morschel

Thanks!

Samuel Rawlins

This is done.

Felipe Morschel

Yes and I've pushed a new patch with the refactoring already. Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 4
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Wed, 03 Sep 2025 21:08:12 +0000
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Oct 10, 2025, 3:39:15 PMOct 10
to Brian Wilkerson, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Samuel Rawlins

Felipe Morschel voted and added 2 comments

Votes added by Felipe Morschel

Auto-Submit+1

2 comments

Patchset-level comments
File-level comment, Patchset 5:
Felipe Morschel . unresolved

I've rebased this one. Can I get some reviews here please? Thanks!

Friendly ping @sraw...@google.com and @brianwi...@google.com

File pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
Line 28, Patchset 5: TypeParameterType? boundFor(DartType? other) {
Felipe Morschel . unresolved

Can I get any thoughts on this method and its doc, please? Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 5
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Fri, 10 Oct 2025 19:39:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Oct 17, 2025, 4:13:12 PMOct 17
to Brian Wilkerson, Samuel Rawlins, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Samuel Rawlins

Felipe Morschel voted Auto-Submit+1

Auto-Submit+1
Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
Gerrit-Change-Number: 442240
Gerrit-PatchSet: 6
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Fri, 17 Oct 2025 20:13:08 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy

Samuel Rawlins (Gerrit)

unread,
Oct 22, 2025, 2:49:42 PM (14 days ago) Oct 22
to Felipe Morschel, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Felipe Morschel

Samuel Rawlins voted and added 8 comments

Votes added by Samuel Rawlins

Code-Review+1

8 comments

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Samuel Rawlins . resolved

Code looks good to me. +1 so I can run bots.

File pkg/analysis_server/lib/src/services/correction/dart/create_setter.dart
Line 58, Patchset 6 (Latest): // else if (target case Identifier(:InstanceElement element)) {
Samuel Rawlins . unresolved

To delete?

File pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
Line 35, Patchset 6 (Latest): var index =
Samuel Rawlins . unresolved

I think this statement is a long way to do `List.indexOf` and `List.indexWhere`, yes? You don't get the nice `??` ability with `-1` if an item is not found, but I think the improved readability is worth that shorthand.

Line 48, Patchset 6 (Latest): } else if (self case FunctionType(
Samuel Rawlins . unresolved

Since we get type promotion on `self`, I think it's easier to just use `else if (self is FunctionType)` and `self.returnType`, `self.typeParameters`, and `self.formalParameters`.

Line 55, Patchset 6 (Latest): .where((type) => type == element)
Samuel Rawlins . unresolved

This looks suspect. This looks like we can just use `element` directly, if `typeParameters.contains(element)`.

And `whereType<TypeParameterType>()` is then not needed. I get the brevity of returning a single (8-line) statement. But I think breaking this up into a few statements using `contains` would make the code more readable.

Line 62, Patchset 6 (Latest): return fields.map((field) => field.type.boundFor(other)).firstOrNull;
Samuel Rawlins . unresolved

`.map.firstOrNull` doesn't look performant. What about

`fields.firstOrNull?.map((f) => f.type.boundFor(other))`

File pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
Line 1695, Patchset 6 (Latest): /// Returns whether the type was written.
Samuel Rawlins . unresolved

I think import to emphasize it does the writing, maybe "Writes [type] if it should be, and returns whether it was written."

Line 1712, Patchset 6 (Latest): if (_canWriteType(
Samuel Rawlins . unresolved

Just for readability, can we break this up into some early returns? Something like:

```dart
// this is the cheaper check
if (!shouldWriteDynamic && visibleType is DynamicType) return false;
if (!_canWriteType(...)) return false;
//...
```

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Felipe Morschel
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
    Gerrit-Change-Number: 442240
    Gerrit-PatchSet: 6
    Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
    Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
    Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
    Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
    Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
    Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
    Gerrit-Comment-Date: Wed, 22 Oct 2025 18:49:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Felipe Morschel (Gerrit)

    unread,
    Oct 23, 2025, 12:08:54 AM (13 days ago) Oct 23
    to Commit Queue, Samuel Rawlins, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
    Attention needed from Brian Wilkerson and Samuel Rawlins

    Felipe Morschel voted and added 7 comments

    Votes added by Felipe Morschel

    Auto-Submit+1

    7 comments

    File pkg/analysis_server/lib/src/services/correction/dart/create_setter.dart
    Line 58, Patchset 6: // else if (target case Identifier(:InstanceElement element)) {
    Samuel Rawlins . resolved

    To delete?

    Felipe Morschel

    Yes, thanks! Forgot about it.

    File pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
    Line 35, Patchset 6: var index =
    Samuel Rawlins . resolved

    I think this statement is a long way to do `List.indexOf` and `List.indexWhere`, yes? You don't get the nice `??` ability with `-1` if an item is not found, but I think the improved readability is worth that shorthand.

    Felipe Morschel

    I think I made it better by just iterating on it once and handling it all inside a `for`. If you prefer I use the methods above instead still, please say so. Thanks!

    Line 48, Patchset 6: } else if (self case FunctionType(
    Samuel Rawlins . resolved

    Since we get type promotion on `self`, I think it's easier to just use `else if (self is FunctionType)` and `self.returnType`, `self.typeParameters`, and `self.formalParameters`.

    Felipe Morschel

    Done

    Line 55, Patchset 6: .where((type) => type == element)
    Samuel Rawlins . resolved

    This looks suspect. This looks like we can just use `element` directly, if `typeParameters.contains(element)`.

    And `whereType<TypeParameterType>()` is then not needed. I get the brevity of returning a single (8-line) statement. But I think breaking this up into a few statements using `contains` would make the code more readable.

    Felipe Morschel

    Thanks!


    Although I was thinking a bit more about this method and I could not think of a way for a type parameter to be infered by some function or record like this. It would always be resolved normally.


    The only case I could think of was classes. I've ended up removing this part and the one for records entirely and all tests pass. If we ever think of a new way this method can be improved we can do so then.

    Line 62, Patchset 6: return fields.map((field) => field.type.boundFor(other)).firstOrNull;
    Samuel Rawlins . resolved

    `.map.firstOrNull` doesn't look performant. What about

    `fields.firstOrNull?.map((f) => f.type.boundFor(other))`

    Felipe Morschel

    Done

    File pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart
    Line 1695, Patchset 6: /// Returns whether the type was written.
    Samuel Rawlins . resolved

    I think import to emphasize it does the writing, maybe "Writes [type] if it should be, and returns whether it was written."

    Felipe Morschel

    Great! Thanks!

    Line 1712, Patchset 6: if (_canWriteType(
    Samuel Rawlins . resolved

    Just for readability, can we break this up into some early returns? Something like:

    ```dart
    // this is the cheaper check
    if (!shouldWriteDynamic && visibleType is DynamicType) return false;
    if (!_canWriteType(...)) return false;
    //...
    ```

    Felipe Morschel

    Thanks!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Brian Wilkerson
    • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
      Gerrit-Change-Number: 442240
      Gerrit-PatchSet: 6
      Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
      Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
      Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
      Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
      Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
      Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
      Gerrit-Comment-Date: Thu, 23 Oct 2025 04:08:51 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Samuel Rawlins <sraw...@google.com>
      unsatisfied_requirement
      open
      diffy

      Samuel Rawlins (Gerrit)

      unread,
      Oct 23, 2025, 1:47:39 PM (13 days ago) Oct 23
      to Felipe Morschel, Commit Queue, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
      Attention needed from Brian Wilkerson and Felipe Morschel

      Samuel Rawlins voted Code-Review+1

      Code-Review+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Brian Wilkerson
      • Felipe Morschel
      Submit Requirements:
        • requirement is not satisfiedCode-Owners
        • requirement 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
        Gerrit-Change-Number: 442240
        Gerrit-PatchSet: 8
        Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
        Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
        Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
        Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
        Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
        Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
        Gerrit-Comment-Date: Thu, 23 Oct 2025 17:47:36 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        Brian Wilkerson (Gerrit)

        unread,
        Oct 23, 2025, 7:05:18 PM (12 days ago) Oct 23
        to Felipe Morschel, Samuel Rawlins, Commit Queue, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
        Attention needed from Felipe Morschel

        Brian Wilkerson added 2 comments

        File pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
        Line 28, Patchset 5: TypeParameterType? boundFor(DartType? other) {
        Felipe Morschel . unresolved

        Can I get any thoughts on this method and its doc, please? Thanks!

        Brian Wilkerson

        It took me a while to figure out what this is doing (or at least to think that I understand).

        The name of the method is confusing because the method has nothing to do with bounds. And the comment seems wrong to me.

        What it's really doing, I think, is returning the type parameter that corresponds to the type argument `other` in `this` type (but only when `other` is a type parameter). Maybe a better name would be `typeParameterCorrespondingTo`.

        But if I'm right, then there's a problem. If I have a type `A<B, B>` (for some type parameter `B`), where `A` is declared as `class A<T, U>`, then we can't know whether to return `T` or `U`. I'm guessing that the right semantics is to return `null` when there isn't a unique match, but I haven't verified that.

        Line 30, Patchset 8 (Latest): if (self is InterfaceType) {
        Brian Wilkerson . unresolved

        I think we could remove the need for this check by replacing the `self == null` on line 26 with `self is! InterfaceType`.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Felipe Morschel
        Submit Requirements:
        • requirement is not satisfiedCode-Owners
        • requirement 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
        Gerrit-Change-Number: 442240
        Gerrit-PatchSet: 8
        Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
        Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
        Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
        Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
        Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
        Gerrit-Comment-Date: Thu, 23 Oct 2025 23:05:14 +0000
        unsatisfied_requirement
        satisfied_requirement
        open
        diffy

        Felipe Morschel (Gerrit)

        unread,
        Oct 29, 2025, 7:19:44 AM (7 days ago) Oct 29
        to Samuel Rawlins, Commit Queue, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
        Attention needed from Brian Wilkerson and Samuel Rawlins

        Felipe Morschel voted and added 2 comments

        Votes added by Felipe Morschel

        Auto-Submit+1

        2 comments

        File pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
        Line 28, Patchset 5: TypeParameterType? boundFor(DartType? other) {
        Felipe Morschel . resolved

        Can I get any thoughts on this method and its doc, please? Thanks!

        Brian Wilkerson

        It took me a while to figure out what this is doing (or at least to think that I understand).

        The name of the method is confusing because the method has nothing to do with bounds. And the comment seems wrong to me.

        What it's really doing, I think, is returning the type parameter that corresponds to the type argument `other` in `this` type (but only when `other` is a type parameter). Maybe a better name would be `typeParameterCorrespondingTo`.

        But if I'm right, then there's a problem. If I have a type `A<B, B>` (for some type parameter `B`), where `A` is declared as `class A<T, U>`, then we can't know whether to return `T` or `U`. I'm guessing that the right semantics is to return `null` when there isn't a unique match, but I haven't verified that.

        Felipe Morschel

        Maybe a better name would be `typeParameterCorrespondingTo`.


        Thanks! I was struggling a bit to come up with this when working on this originally. I'll be sure to rename and review the comments.


        > But if I'm right, then there's a problem. If I have a type `A<B, B>` (for some type parameter `B`), where `A` is declared as class `A<T, U>`, then we can't know whether to return `T` or `U`. I'm guessing that the right semantics is to return `null` when there isn't a unique match, but I haven't verified that.


        I guess so too, I'd not thought of this case. I'll be sure to add a test case and verify we are doing the correct thing here. This would fall-back to the bound on `B` so we should be safe.

        Line 30, Patchset 8: if (self is InterfaceType) {
        Brian Wilkerson . resolved

        I think we could remove the need for this check by replacing the `self == null` on line 26 with `self is! InterfaceType`.

        Felipe Morschel

        Great idea! Originally I was having some trouble with the semantics here and I did some work for `RecordType` and `FunctionType` but they can't do the same here.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Brian Wilkerson
        • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
          Gerrit-Change-Number: 442240
          Gerrit-PatchSet: 8
          Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
          Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
          Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
          Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
          Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
          Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
          Gerrit-Comment-Date: Wed, 29 Oct 2025 11:19:41 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
          Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
          unsatisfied_requirement
          open
          diffy

          Brian Wilkerson (Gerrit)

          unread,
          Oct 29, 2025, 11:57:23 AM (7 days ago) Oct 29
          to Felipe Morschel, Brian Wilkerson, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
          Attention needed from Felipe Morschel and Samuel Rawlins

          Brian Wilkerson voted and added 1 comment

          Votes added by Brian Wilkerson

          Commit-Queue+1

          1 comment

          File pkg/analysis_server/test/src/services/correction/fix/create_field_test.dart
          Line 332, Patchset 9 (Latest):T? g<T>(A a) => a.field;
          Brian Wilkerson . unresolved

          The resulting code generates a diagnostic:

          A value of type 'Object?' can't be returned from the function 'g' because it has a return type of 'T?'. (return_of_invalid_type)

          The only solution I can think of is to add a cast, which I don't think we want to do as part of generating the field.

          I suppose the right way to think of this is that it's better to offer help getting closer to an eventual solution even if it's just trading one diagnostic for another than it is to offer no help at all?

          Note that the next test has the same problem.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Felipe Morschel
          • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
          Gerrit-Change-Number: 442240
          Gerrit-PatchSet: 9
          Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
          Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
          Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
          Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
          Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
          Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
          Gerrit-Comment-Date: Wed, 29 Oct 2025 15:57:19 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          unsatisfied_requirement
          open
          diffy

          Felipe Morschel (Gerrit)

          unread,
          Oct 29, 2025, 12:10:44 PM (7 days ago) Oct 29
          to Brian Wilkerson, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
          Attention needed from Brian Wilkerson and Samuel Rawlins

          Felipe Morschel voted and added 1 comment

          Votes added by Felipe Morschel

          Auto-Submit+1

          1 comment

          File pkg/analysis_server/test/src/services/correction/fix/create_field_test.dart
          Line 332, Patchset 9 (Latest):T? g<T>(A a) => a.field;
          Brian Wilkerson . unresolved

          The resulting code generates a diagnostic:

          A value of type 'Object?' can't be returned from the function 'g' because it has a return type of 'T?'. (return_of_invalid_type)

          The only solution I can think of is to add a cast, which I don't think we want to do as part of generating the field.

          I suppose the right way to think of this is that it's better to offer help getting closer to an eventual solution even if it's just trading one diagnostic for another than it is to offer no help at all?

          Note that the next test has the same problem.

          Felipe Morschel

          I'd prefer having the assist rather than having none because this way, I can continue my train of thought. It just so happens that there is no good way for the tooling to ever suggest a good fix here that is not `dynamic` and this is not something that would work in strict mode either so I'd say to leave this as is.


          We even have two different fixes for this new diagnostic:

          • Change the return type
          • Add cast


          So the user will be well served of tolling fixes here for this whole process.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Brian Wilkerson
          • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
          Gerrit-Change-Number: 442240
          Gerrit-PatchSet: 9
          Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
          Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
          Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
          Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
          Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
          Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
          Gerrit-Comment-Date: Wed, 29 Oct 2025 16:10:40 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
          unsatisfied_requirement
          open
          diffy

          Brian Wilkerson (Gerrit)

          unread,
          Oct 29, 2025, 1:48:11 PM (7 days ago) Oct 29
          to Felipe Morschel, Brian Wilkerson, Samuel Rawlins, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
          Attention needed from Felipe Morschel and Samuel Rawlins

          Brian Wilkerson voted and added 2 comments

          Votes added by Brian Wilkerson

          Code-Review+1

          2 comments

          Patchset-level comments
          File-level comment, Patchset 5:
          Felipe Morschel . resolved

          I've rebased this one. Can I get some reviews here please? Thanks!

          Friendly ping @sraw...@google.com and @brianwi...@google.com

          Brian Wilkerson

          Acknowledged

          File pkg/analysis_server/test/src/services/correction/fix/create_field_test.dart
          Line 332, Patchset 9 (Latest):T? g<T>(A a) => a.field;
          Brian Wilkerson . resolved

          The resulting code generates a diagnostic:

          A value of type 'Object?' can't be returned from the function 'g' because it has a return type of 'T?'. (return_of_invalid_type)

          The only solution I can think of is to add a cast, which I don't think we want to do as part of generating the field.

          I suppose the right way to think of this is that it's better to offer help getting closer to an eventual solution even if it's just trading one diagnostic for another than it is to offer no help at all?

          Note that the next test has the same problem.

          Felipe Morschel

          I'd prefer having the assist rather than having none because this way, I can continue my train of thought. It just so happens that there is no good way for the tooling to ever suggest a good fix here that is not `dynamic` and this is not something that would work in strict mode either so I'd say to leave this as is.


          We even have two different fixes for this new diagnostic:

          • Change the return type
          • Add cast


          So the user will be well served of tolling fixes here for this whole process.

          Brian Wilkerson

          Yeah, I agree.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Felipe Morschel
          • Samuel Rawlins
          Submit Requirements:
            • requirement is not satisfiedCode-Owners
            • requirement 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
            Gerrit-Change-Number: 442240
            Gerrit-PatchSet: 9
            Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
            Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
            Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
            Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
            Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
            Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
            Gerrit-Comment-Date: Wed, 29 Oct 2025 17:48:06 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: Yes
            Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
            Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
            unsatisfied_requirement
            satisfied_requirement
            open
            diffy

            Samuel Rawlins (Gerrit)

            unread,
            Oct 30, 2025, 11:09:37 AM (6 days ago) Oct 30
            to Felipe Morschel, Brian Wilkerson, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
            Attention needed from Felipe Morschel

            Samuel Rawlins voted and added 1 comment

            Votes added by Samuel Rawlins

            Code-Review+1

            1 comment

            File pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
            Line 26, Patchset 9 (Latest): TypeParameterType? typeParameterCorrespondingTo(DartType? other) {
            Samuel Rawlins . resolved

            Yes! Better name and better docs. 👍

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Felipe Morschel
            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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
              Gerrit-Change-Number: 442240
              Gerrit-PatchSet: 9
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Comment-Date: Thu, 30 Oct 2025 15:09:33 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: Yes
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy

              Samuel Rawlins (Gerrit)

              unread,
              Oct 30, 2025, 11:10:00 AM (6 days ago) Oct 30
              to Felipe Morschel, Konstantin Shcheglov, Brian Wilkerson, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Felipe Morschel and Konstantin Shcheglov

              Samuel Rawlins voted Commit-Queue+1

              Commit-Queue+1
              Open in Gerrit

              Related details

              Attention is currently required from:
              • Felipe Morschel
              • Konstantin Shcheglov
              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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
              Gerrit-Change-Number: 442240
              Gerrit-PatchSet: 9
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Comment-Date: Thu, 30 Oct 2025 15:09:57 +0000
              Gerrit-HasComments: No
              Gerrit-Has-Labels: Yes
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy

              Konstantin Shcheglov (Gerrit)

              unread,
              Oct 30, 2025, 3:30:04 PM (5 days ago) Oct 30
              to Felipe Morschel, Samuel Rawlins, Brian Wilkerson, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Felipe Morschel

              Konstantin Shcheglov added 2 comments

              File pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
              Line 26, Patchset 9 (Latest): TypeParameterType? typeParameterCorrespondingTo(DartType? other) {
              Konstantin Shcheglov . unresolved

              This is a quite wide extension doing something specific for quick fixes.
              And because it is wide, it will fire on every type in the analyzer, without being useful.

              It probably does not belong to the analyzer package..

              Line 39, Patchset 9 (Latest): } else if (current.typeParameterCorrespondingTo(other) != null) {
              Konstantin Shcheglov . unresolved

              I don't understand this branch, it looks that it is not documented above.

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Felipe Morschel
              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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
              Gerrit-Change-Number: 442240
              Gerrit-PatchSet: 9
              Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
              Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
              Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
              Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
              Gerrit-Comment-Date: Thu, 30 Oct 2025 19:30:01 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: No
              unsatisfied_requirement
              satisfied_requirement
              open
              diffy

              Felipe Morschel (Gerrit)

              unread,
              Oct 30, 2025, 11:14:19 PM (5 days ago) Oct 30
              to Konstantin Shcheglov, Samuel Rawlins, Brian Wilkerson, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
              Attention needed from Brian Wilkerson and Samuel Rawlins

              Felipe Morschel voted and added 2 comments

              Votes added by Felipe Morschel

              Auto-Submit+1

              2 comments

              File pkg/analyzer/lib/src/utilities/extensions/dart_type.dart
              Line 26, Patchset 9: TypeParameterType? typeParameterCorrespondingTo(DartType? other) {
              Konstantin Shcheglov . resolved

              This is a quite wide extension doing something specific for quick fixes.
              And because it is wide, it will fire on every type in the analyzer, without being useful.

              It probably does not belong to the analyzer package..

              Felipe Morschel

              Alright, then. I'll move into the `analysis_server` and defer to Sam and Brian if they agree it should be there. Thanks!

              Line 39, Patchset 9: } else if (current.typeParameterCorrespondingTo(other) != null) {
              Konstantin Shcheglov . resolved

              I don't understand this branch, it looks that it is not documented above.

              Felipe Morschel

              Oh, I don't think it is necessary. I've removed it and no test failed. I'll remove this. Thanks!

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Brian Wilkerson
              • 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
                Gerrit-Change-Number: 442240
                Gerrit-PatchSet: 9
                Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
                Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                Gerrit-CC: Konstantin Shcheglov <sche...@google.com>
                Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
                Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
                Gerrit-Comment-Date: Fri, 31 Oct 2025 03:14:16 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: Yes
                Comment-In-Reply-To: Konstantin Shcheglov <sche...@google.com>
                unsatisfied_requirement
                open
                diffy

                Samuel Rawlins (Gerrit)

                unread,
                Nov 1, 2025, 5:40:50 PM (3 days ago) Nov 1
                to Felipe Morschel, Konstantin Shcheglov, Brian Wilkerson, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
                Attention needed from Brian Wilkerson and Felipe Morschel

                Samuel Rawlins voted Code-Review+1

                Code-Review+1
                Open in Gerrit

                Related details

                Attention is currently required from:
                • Brian Wilkerson
                • Felipe Morschel
                Submit Requirements:
                • requirement satisfiedCode-Owners
                • requirement 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: Ib70937ce8232ec087cf95d12d52a1bfdf59ad3ba
                Gerrit-Change-Number: 442240
                Gerrit-PatchSet: 10
                Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
                Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
                Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
                Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
                Gerrit-CC: Konstantin Shcheglov <sche...@google.com>
                Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
                Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
                Gerrit-Comment-Date: Sat, 01 Nov 2025 21:40:46 +0000
                Gerrit-HasComments: No
                Gerrit-Has-Labels: Yes
                satisfied_requirement
                unsatisfied_requirement
                open
                diffy
                Reply all
                Reply to author
                Forward
                0 new messages