Skip to content

Commit a565406

Browse files
chloestefantsovaCommit Queue
authored andcommitted
[cfe] Implement a formal list helper as an extension method
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/405006 Change-Id: Ic3c2c5a572beda06c511a4bfc25cd1526f1b09d5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404825 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Chloe Stefantsova <[email protected]>
1 parent d200098 commit a565406

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

pkg/front_end/lib/src/source/source_constructor_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ class DeclaredSourceConstructorBuilder
880880
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
881881
if (_hasBuiltOutlines) return;
882882

883-
inferFormals(formals, classHierarchy);
883+
formals?.infer(classHierarchy);
884884

885885
if (isConst && isAugmenting) {
886886
origin.buildOutlineExpressions(

pkg/front_end/lib/src/source/source_factory_builder.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class SourceFactoryBuilder extends SourceFunctionBuilderImpl {
263263
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
264264
if (_hasBuiltOutlines) return;
265265

266-
inferFormals(formals, classHierarchy);
266+
formals?.infer(classHierarchy);
267267

268268
if (_delayedDefaultValueCloner != null) {
269269
delayedDefaultValueCloners.add(_delayedDefaultValueCloner!);
@@ -563,7 +563,7 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder {
563563
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
564564
if (_hasBuiltOutlines) return;
565565

566-
inferFormals(formals, classHierarchy);
566+
formals?.infer(classHierarchy);
567567

568568
if (isConst && isAugmenting) {
569569
origin.buildOutlineExpressions(

pkg/front_end/lib/src/source/source_function_builder.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ abstract class SourceFunctionBuilderImpl extends SourceMemberBuilderImpl
423423
void buildOutlineExpressions(ClassHierarchy classHierarchy,
424424
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
425425
if (!hasBuiltOutlineExpressions) {
426-
inferFormals(formals, classHierarchy);
426+
formals?.infer(classHierarchy);
427427

428428
DeclarationBuilder? classOrExtensionBuilder =
429429
isClassMember || isExtensionMember || isExtensionTypeMember
@@ -575,11 +575,10 @@ void reportAugmentationMismatch(
575575
]);
576576
}
577577

578-
/// Ensures the type of each of the [formals] is inferred.
579-
void inferFormals(
580-
List<FormalParameterBuilder>? formals, ClassHierarchy classHierarchy) {
581-
if (formals != null) {
582-
for (FormalParameterBuilder formal in formals) {
578+
extension FormalsMethods on List<FormalParameterBuilder> {
579+
/// Ensures the type of each of the formals is inferred.
580+
void infer(ClassHierarchy classHierarchy) {
581+
for (FormalParameterBuilder formal in this) {
583582
TypeBuilder formalType = formal.type;
584583
if (formalType is InferableTypeBuilder) {
585584
formalType.inferType(classHierarchy);

pkg/front_end/test/coverage_suite_expected.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
920920
),
921921
// 100.0%.
922922
"package:front_end/src/source/source_constructor_builder.dart": (
923-
hitCount: 891,
923+
hitCount: 893,
924924
missCount: 0,
925925
),
926926
// 100.0%.
@@ -941,13 +941,13 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
941941
),
942942
// 100.0%.
943943
"package:front_end/src/source/source_factory_builder.dart": (
944-
hitCount: 593,
944+
hitCount: 590,
945945
missCount: 0,
946946
),
947-
// 100.0%.
947+
// 99.60317460317461%.
948948
"package:front_end/src/source/source_function_builder.dart": (
949-
hitCount: 243,
950-
missCount: 0,
949+
hitCount: 251,
950+
missCount: 1,
951951
),
952952
// 100.0%.
953953
"package:front_end/src/source/source_library_builder.dart": (

0 commit comments

Comments
 (0)