Skip to content

Commit a3085e7

Browse files
johnniwintherCommit Queue
authored andcommitted
[cfe] Move computeDefaultType to SourceMember/DeclarationBuilder
Change-Id: Ib37e7d6115a5e5f42b57c3a7d8e4bc10c8d78165 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391401 Reviewed-by: Chloe Stefantsova <[email protected]>
1 parent 4c8c0da commit a3085e7

14 files changed

+407
-378
lines changed

pkg/front_end/lib/src/base/incremental_compiler.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,8 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
19851985
isAugmenting: false,
19861986
indexedLibrary: null,
19871987
mayImplementRestrictedTypes: false);
1988+
debugCompilationUnit.markLanguageVersionFinal();
1989+
19881990
SourceLibraryBuilder debugLibrary = debugCompilationUnit.createLibrary();
19891991
debugLibrary.buildNameSpace();
19901992
libraryBuilder.libraryNameSpace.forEachLocalMember((name, member) {
@@ -2047,6 +2049,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
20472049
isAugmenting: false,
20482050
indexedLibrary: null,
20492051
mayImplementRestrictedTypes: false);
2052+
debugCompilationUnit.markLanguageVersionFinal();
20502053

20512054
SourceLibraryBuilder? orgDebugLibrary = debugLibrary;
20522055
debugLibrary = debugCompilationUnit.createLibrary();

pkg/front_end/lib/src/base/scope.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import '../kernel/body_builder_context.dart';
2020
import '../kernel/hierarchy/class_member.dart' show ClassMember;
2121
import '../kernel/kernel_helper.dart';
2222
import '../kernel/load_library_builder.dart';
23+
import '../kernel/type_algorithms.dart';
2324
import '../source/source_class_builder.dart';
2425
import '../source/source_extension_builder.dart';
2526
import '../source/source_extension_type_declaration_builder.dart';
@@ -722,6 +723,14 @@ mixin ErroneousMemberBuilderMixin implements SourceMemberBuilder {
722723
return 0;
723724
}
724725

726+
@override
727+
// Coverage-ignore(suite): Not run.
728+
int computeDefaultTypes(ComputeDefaultTypeContext context,
729+
{required bool inErrorRecovery}) {
730+
assert(false, "Unexpected call to $runtimeType.computeDefaultTypes.");
731+
return 0;
732+
}
733+
725734
@override
726735
// Coverage-ignore(suite): Not run.
727736
List<ClassMember> get localMembers => const <ClassMember>[];

pkg/front_end/lib/src/kernel/type_algorithms.dart

Lines changed: 234 additions & 73 deletions
Large diffs are not rendered by default.

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import '../builder/procedure_builder.dart';
1919
import '../builder/type_builder.dart';
2020
import '../kernel/body_builder_context.dart';
2121
import '../kernel/kernel_helper.dart';
22+
import '../kernel/type_algorithms.dart';
2223
import 'source_constructor_builder.dart';
2324
import 'source_field_builder.dart';
2425
import 'source_library_builder.dart';
@@ -28,6 +29,8 @@ import 'source_procedure_builder.dart';
2829

2930
abstract class SourceDeclarationBuilder implements IDeclarationBuilder {
3031
void buildScopes(LibraryBuilder coreLibrary);
32+
33+
int computeDefaultTypes(ComputeDefaultTypeContext context);
3134
}
3235

3336
mixin SourceDeclarationBuilderMixin
@@ -126,6 +129,35 @@ mixin SourceDeclarationBuilderMixin
126129
return count;
127130
}
128131

132+
@override
133+
int computeDefaultTypes(ComputeDefaultTypeContext context) {
134+
bool hasErrors = context.reportNonSimplicityIssues(this, typeParameters);
135+
int count = context.computeDefaultTypesForVariables(typeParameters,
136+
inErrorRecovery: hasErrors);
137+
138+
Iterator<SourceMemberBuilder> iterator =
139+
nameSpace.filteredConstructorIterator<SourceMemberBuilder>(
140+
parent: this, includeDuplicates: false, includeAugmentations: true);
141+
while (iterator.moveNext()) {
142+
count += iterator.current
143+
.computeDefaultTypes(context, inErrorRecovery: hasErrors);
144+
}
145+
146+
forEach((String name, Builder member) {
147+
if (member is SourceMemberBuilder) {
148+
count +=
149+
member.computeDefaultTypes(context, inErrorRecovery: hasErrors);
150+
} else {
151+
// Coverage-ignore-block(suite): Not run.
152+
assert(
153+
false,
154+
"Unexpected extension type member "
155+
"$member (${member.runtimeType}).");
156+
}
157+
});
158+
return count;
159+
}
160+
129161
void checkTypesInOutline(TypeEnvironment typeEnvironment) {
130162
forEach((String name, Builder builder) {
131163
if (builder is SourceFieldBuilder) {

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import '../kernel/body_builder_context.dart';
4242
import '../kernel/hierarchy/hierarchy_builder.dart';
4343
import '../kernel/hierarchy/hierarchy_node.dart';
4444
import '../kernel/kernel_helper.dart';
45+
import '../kernel/type_algorithms.dart';
4546
import '../kernel/utils.dart' show compareProcedures;
4647
import 'class_declaration.dart';
4748
import 'name_scheme.dart';
@@ -1147,6 +1148,29 @@ class SourceClassBuilder extends ClassBuilderImpl
11471148
}
11481149
}
11491150

1151+
@override
1152+
int computeDefaultTypes(ComputeDefaultTypeContext context) {
1153+
bool hasErrors = context.reportNonSimplicityIssues(this, typeParameters);
1154+
int count = context.computeDefaultTypesForVariables(typeParameters,
1155+
inErrorRecovery: hasErrors);
1156+
1157+
Iterator<SourceMemberBuilder> iterator =
1158+
nameSpace.filteredConstructorIterator<SourceMemberBuilder>(
1159+
parent: this, includeDuplicates: false, includeAugmentations: true);
1160+
while (iterator.moveNext()) {
1161+
count += iterator.current
1162+
.computeDefaultTypes(context, inErrorRecovery: hasErrors);
1163+
}
1164+
1165+
Iterator<SourceMemberBuilder> memberIterator =
1166+
fullMemberIterator<SourceMemberBuilder>();
1167+
while (memberIterator.moveNext()) {
1168+
count += memberIterator.current
1169+
.computeDefaultTypes(context, inErrorRecovery: hasErrors);
1170+
}
1171+
return count;
1172+
}
1173+
11501174
void checkTypesInOutline(TypeEnvironment typeEnvironment) {
11511175
Iterator<SourceMemberBuilder> memberIterator =
11521176
fullMemberIterator<SourceMemberBuilder>();

0 commit comments

Comments
 (0)