Skip to content

Commit

Permalink
[cfe] Implement a formal list helper as an extension method
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
chloestefantsova authored and Commit Queue committed Jan 20, 2025
1 parent d200098 commit a565406
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ class DeclaredSourceConstructorBuilder
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
if (_hasBuiltOutlines) return;

inferFormals(formals, classHierarchy);
formals?.infer(classHierarchy);

if (isConst && isAugmenting) {
origin.buildOutlineExpressions(
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/lib/src/source/source_factory_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class SourceFactoryBuilder extends SourceFunctionBuilderImpl {
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
if (_hasBuiltOutlines) return;

inferFormals(formals, classHierarchy);
formals?.infer(classHierarchy);

if (_delayedDefaultValueCloner != null) {
delayedDefaultValueCloners.add(_delayedDefaultValueCloner!);
Expand Down Expand Up @@ -563,7 +563,7 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder {
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
if (_hasBuiltOutlines) return;

inferFormals(formals, classHierarchy);
formals?.infer(classHierarchy);

if (isConst && isAugmenting) {
origin.buildOutlineExpressions(
Expand Down
11 changes: 5 additions & 6 deletions pkg/front_end/lib/src/source/source_function_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ abstract class SourceFunctionBuilderImpl extends SourceMemberBuilderImpl
void buildOutlineExpressions(ClassHierarchy classHierarchy,
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
if (!hasBuiltOutlineExpressions) {
inferFormals(formals, classHierarchy);
formals?.infer(classHierarchy);

DeclarationBuilder? classOrExtensionBuilder =
isClassMember || isExtensionMember || isExtensionTypeMember
Expand Down Expand Up @@ -575,11 +575,10 @@ void reportAugmentationMismatch(
]);
}

/// Ensures the type of each of the [formals] is inferred.
void inferFormals(
List<FormalParameterBuilder>? formals, ClassHierarchy classHierarchy) {
if (formals != null) {
for (FormalParameterBuilder formal in formals) {
extension FormalsMethods on List<FormalParameterBuilder> {
/// Ensures the type of each of the formals is inferred.
void infer(ClassHierarchy classHierarchy) {
for (FormalParameterBuilder formal in this) {
TypeBuilder formalType = formal.type;
if (formalType is InferableTypeBuilder) {
formalType.inferType(classHierarchy);
Expand Down
10 changes: 5 additions & 5 deletions pkg/front_end/test/coverage_suite_expected.dart
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/source/source_constructor_builder.dart": (
hitCount: 891,
hitCount: 893,
missCount: 0,
),
// 100.0%.
Expand All @@ -941,13 +941,13 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/source/source_factory_builder.dart": (
hitCount: 593,
hitCount: 590,
missCount: 0,
),
// 100.0%.
// 99.60317460317461%.
"package:front_end/src/source/source_function_builder.dart": (
hitCount: 243,
missCount: 0,
hitCount: 251,
missCount: 1,
),
// 100.0%.
"package:front_end/src/source/source_library_builder.dart": (
Expand Down

0 comments on commit a565406

Please sign in to comment.