Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(731)

Unified Diff: pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart

Issue 2746763003: Add default type arguments on Supertype as well. (Closed)
Patch Set: Rebased on 1cb1b70d5daf9ec7f24a98be9d2fdac919ae0c24. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
index 185e1d5d84c590684544cbb13d11698cb2d9566a..347b08488602aa4c7a6d0b70cbe950d7d90611d9 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart
@@ -64,44 +64,37 @@ abstract class KernelClassBuilder
/// [arguments] have already been built.
InterfaceType buildTypesWithBuiltArguments(
LibraryBuilder library, List<DartType> arguments) {
- return arguments == null
- ? cls.rawType
- : new InterfaceType(
- cls,
- // TODO(ahe): Not sure what to do if `arguments.length !=
- // cls.typeParameters.length`.
- computeDefaultTypeArguments(cls.typeParameters, arguments));
+ assert(arguments == null || cls.typeParameters.length == arguments.length);
+ return arguments == null ? cls.rawType : new InterfaceType(cls, arguments);
+ }
+
+ List<DartType> buildTypeArguments(
+ LibraryBuilder library, List<KernelTypeBuilder> arguments) {
+ List<DartType> typeArguments = <DartType>[];
+ for (KernelTypeBuilder builder in arguments) {
+ DartType type = builder.build(library);
+ if (type == null) {
+ internalError("Bad type: ${builder.runtimeType}");
+ }
+ typeArguments.add(type);
+ }
+ return computeDefaultTypeArguments(
+ library, cls.typeParameters, typeArguments);
}
InterfaceType buildType(
LibraryBuilder library, List<KernelTypeBuilder> arguments) {
List<DartType> typeArguments;
if (arguments != null) {
- typeArguments = <DartType>[];
- for (KernelTypeBuilder builder in arguments) {
- DartType type = builder.build(library);
- if (type == null) {
- internalError("Bad type: ${builder.runtimeType}");
- }
- typeArguments.add(type);
- }
+ typeArguments = buildTypeArguments(library, arguments);
}
return buildTypesWithBuiltArguments(library, typeArguments);
}
Supertype buildSupertype(
LibraryBuilder library, List<KernelTypeBuilder> arguments) {
- List<DartType> typeArguments;
if (arguments != null) {
- typeArguments = <DartType>[];
- for (KernelTypeBuilder builder in arguments) {
- DartType type = builder.build(library);
- if (type == null) {
- internalError("Bad type: ${builder.runtimeType}");
- }
- typeArguments.add(type);
- }
- return new Supertype(cls, typeArguments);
+ return new Supertype(cls, buildTypeArguments(library, arguments));
} else {
return cls.asRawSupertype;
}

Powered by Google App Engine
This is Rietveld 408576698