[M] Change in dart/sdk[main]: [modular_aot] Reuse class and function type arguments when instantiating

0 views
Skip to first unread message

Alexander Markov (Gerrit)

unread,
Jun 23, 2026, 7:32:19 PM (22 hours ago) Jun 23
to Alexander Markov, Slava Egorov, Nate Biggs, Alexander Aprelev, Tess Strickland, Nicholas Shahan, Stephen Adams, dart-...@luci-project-accounts.iam.gserviceaccount.com, rev...@dartlang.org
Attention needed from Slava Egorov

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Slava Egorov
Submit Requirements:
  • requirement 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: I200b2d348c89b221c08554ed1654f7ad8bc3ef90
Gerrit-Change-Number: 516440
Gerrit-PatchSet: 2
Gerrit-Owner: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Alexander Aprelev <a...@google.com>
Gerrit-CC: Nate Biggs <nate...@google.com>
Gerrit-CC: Nicholas Shahan <nsh...@google.com>
Gerrit-CC: Stephen Adams <s...@google.com>
Gerrit-CC: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Comment-Date: Tue, 23 Jun 2026 23:32:13 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Slava Egorov (Gerrit)

unread,
7:45 AM (10 hours ago) 7:45 AM
to Alexander Markov, Nate Biggs, Alexander Aprelev, Tess Strickland, Nicholas Shahan, Stephen Adams, dart-...@luci-project-accounts.iam.gserviceaccount.com, rev...@dartlang.org
Attention needed from Alexander Markov

Slava Egorov voted and added 1 comment

Votes added by Slava Egorov

Code-Review+1

1 comment

File pkg/native_compiler/lib/runtime/type_utils.dart
Line 139, Patchset 2 (Latest):bool canReuseClassTypeArguments(List<ast.DartType> types) {
Slava Egorov . unresolved

Maybe something like this is easier to read?

```
enum TypeParametersReuse {
function, class, none
}
TypeParametersReuse computeTypeParametersReuse(List<ast.DartType> types) {
final type = types[0];
if (type is! ast.TypeParameterType || type.nullability == .nullable) {
return .none;
}
final decl = type.parameter.declaration;
if (types.length > decl.typeParameters.length) {
return .none;
}
for (int i = 1; i < types.length; ++i) {
final type = types[i];
if (type is! ast.TypeParameterType || type.nullability == .nullable || type.parameter != decl.typeParameters[i]) {
return .none;
}
}
if (decl is ast.Class) {
if (getNumberOfInstantiatorTypeArguments(cls) != cls.typeParameters.length) {
return .none;
}
return .class;
} else if (decl is ast.Procedure) {
return .function;
}
return .none;
}
```
Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Markov
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: I200b2d348c89b221c08554ed1654f7ad8bc3ef90
Gerrit-Change-Number: 516440
Gerrit-PatchSet: 2
Gerrit-Owner: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Alexander Aprelev <a...@google.com>
Gerrit-CC: Nate Biggs <nate...@google.com>
Gerrit-CC: Nicholas Shahan <nsh...@google.com>
Gerrit-CC: Stephen Adams <s...@google.com>
Gerrit-CC: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Alexander Markov <alexm...@google.com>
Gerrit-Comment-Date: Wed, 24 Jun 2026 11:45:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Alexander Markov (Gerrit)

unread,
12:54 PM (4 hours ago) 12:54 PM
to Alexander Markov, Slava Egorov, Nate Biggs, Alexander Aprelev, Tess Strickland, Nicholas Shahan, Stephen Adams, dart-...@luci-project-accounts.iam.gserviceaccount.com, rev...@dartlang.org
Attention needed from Alexander Markov and Slava Egorov

Alexander Markov removed a vote from this change

Removed Code-Review+1 by Slava Egorov <veg...@google.com>
Open in Gerrit

Related details

Attention is currently required from:
  • Alexander Markov
  • Slava Egorov
Submit Requirements:
  • requirement 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: deleteVote
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I200b2d348c89b221c08554ed1654f7ad8bc3ef90
Gerrit-Change-Number: 516440
Gerrit-PatchSet: 3
Gerrit-Owner: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Alexander Aprelev <a...@google.com>
Gerrit-CC: Nate Biggs <nate...@google.com>
Gerrit-CC: Nicholas Shahan <nsh...@google.com>
Gerrit-CC: Stephen Adams <s...@google.com>
Gerrit-CC: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Alexander Markov <alexm...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Alexander Markov (Gerrit)

unread,
12:54 PM (4 hours ago) 12:54 PM
to Alexander Markov, Slava Egorov, Nate Biggs, Alexander Aprelev, Tess Strickland, Nicholas Shahan, Stephen Adams, dart-...@luci-project-accounts.iam.gserviceaccount.com, rev...@dartlang.org
Attention needed from Slava Egorov

Alexander Markov added 1 comment

File pkg/native_compiler/lib/runtime/type_utils.dart
Line 139, Patchset 2:bool canReuseClassTypeArguments(List<ast.DartType> types) {
Slava Egorov . resolved

Maybe something like this is easier to read?

```
enum TypeParametersReuse {
function, class, none
}
TypeParametersReuse computeTypeParametersReuse(List<ast.DartType> types) {
final type = types[0];
if (type is! ast.TypeParameterType || type.nullability == .nullable) {
return .none;
}
final decl = type.parameter.declaration;
if (types.length > decl.typeParameters.length) {
return .none;
}
for (int i = 1; i < types.length; ++i) {
final type = types[i];
if (type is! ast.TypeParameterType || type.nullability == .nullable || type.parameter != decl.typeParameters[i]) {
return .none;
}
}
if (decl is ast.Class) {
if (getNumberOfInstantiatorTypeArguments(cls) != cls.typeParameters.length) {
return .none;
}
return .class;
} else if (decl is ast.Procedure) {
return .function;
}
return .none;
}
```
Alexander Markov

Thank you for the suggestion!

I merged both predicates to a single function with enum result as you suggested. While doing this, I realized that we can reuse instantiator (class) type arguments in more cases, so I changed the logic accordingly and extracted `_isPrefixOf` helper.

Please take a look once again.

Open in Gerrit

Related details

Attention is currently required from:
  • Slava Egorov
Submit Requirements:
  • requirement 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: I200b2d348c89b221c08554ed1654f7ad8bc3ef90
Gerrit-Change-Number: 516440
Gerrit-PatchSet: 3
Gerrit-Owner: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Alexander Markov <alexm...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-CC: Alexander Aprelev <a...@google.com>
Gerrit-CC: Nate Biggs <nate...@google.com>
Gerrit-CC: Nicholas Shahan <nsh...@google.com>
Gerrit-CC: Stephen Adams <s...@google.com>
Gerrit-CC: Tess Strickland <sstr...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Comment-Date: Wed, 24 Jun 2026 16:54:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Slava Egorov <veg...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages