| Index: pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart
|
| diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart
|
| index 4b083dcdaebffee0f62d1d375e97a859976e2be6..6e59e546f8846ee413eaea93a4a5ce57f6b67804 100644
|
| --- a/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart
|
| +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart
|
| @@ -4,6 +4,7 @@
|
|
|
| library fasta.kernel_function_type_alias_builder;
|
|
|
| +import 'package:front_end/src/fasta/util/relativize.dart';
|
| import 'package:kernel/ast.dart'
|
| show
|
| DartType,
|
| @@ -11,17 +12,17 @@ import 'package:kernel/ast.dart'
|
| FunctionType,
|
| InvalidType,
|
| NamedType,
|
| - TypeParameter;
|
| -
|
| + TypeParameter,
|
| + Typedef;
|
| import 'package:kernel/type_algebra.dart' show substitute;
|
|
|
| import '../messages.dart' show warning;
|
| -
|
| import 'kernel_builder.dart'
|
| show
|
| FormalParameterBuilder,
|
| FunctionTypeAliasBuilder,
|
| KernelFormalParameterBuilder,
|
| + KernelLibraryBuilder,
|
| KernelTypeBuilder,
|
| KernelTypeVariableBuilder,
|
| LibraryBuilder,
|
| @@ -46,6 +47,14 @@ class KernelFunctionTypeAliasBuilder
|
| : super(metadata, returnType, name, typeVariables, formals, parent,
|
| charOffset);
|
|
|
| + Typedef build(KernelLibraryBuilder libraryBuilder) {
|
| + DartType type = buildThisType(libraryBuilder);
|
| + var typedef = new Typedef(name, type);
|
| + typedef.fileUri = relativizeUri(parent.fileUri);
|
| + typedef.fileOffset = charOffset;
|
| + return typedef;
|
| + }
|
| +
|
| DartType buildThisType(LibraryBuilder library) {
|
| if (thisType != null) {
|
| if (thisType == const InvalidType()) {
|
| @@ -90,22 +99,6 @@ class KernelFunctionTypeAliasBuilder
|
| requiredParameterCount: requiredParameterCount);
|
| }
|
|
|
| - /// [arguments] have already been built.
|
| - DartType buildTypesWithBuiltArguments(
|
| - LibraryBuilder library, List<DartType> arguments) {
|
| - var thisType = buildThisType(library);
|
| - if (thisType is DynamicType) return thisType;
|
| - FunctionType result = thisType;
|
| - if (result.typeParameters.isEmpty && arguments == null) return result;
|
| - arguments =
|
| - computeDefaultTypeArguments(library, result.typeParameters, arguments);
|
| - Map<TypeParameter, DartType> substitution = <TypeParameter, DartType>{};
|
| - for (int i = 0; i < result.typeParameters.length; i++) {
|
| - substitution[result.typeParameters[i]] = arguments[i];
|
| - }
|
| - return substitute(result.withoutTypeParameters, substitution);
|
| - }
|
| -
|
| DartType buildType(
|
| LibraryBuilder library, List<KernelTypeBuilder> arguments) {
|
| var thisType = buildThisType(library);
|
| @@ -121,4 +114,20 @@ class KernelFunctionTypeAliasBuilder
|
| }
|
| return buildTypesWithBuiltArguments(library, builtArguments);
|
| }
|
| +
|
| + /// [arguments] have already been built.
|
| + DartType buildTypesWithBuiltArguments(
|
| + LibraryBuilder library, List<DartType> arguments) {
|
| + var thisType = buildThisType(library);
|
| + if (thisType is DynamicType) return thisType;
|
| + FunctionType result = thisType;
|
| + if (result.typeParameters.isEmpty && arguments == null) return result;
|
| + arguments =
|
| + computeDefaultTypeArguments(library, result.typeParameters, arguments);
|
| + Map<TypeParameter, DartType> substitution = <TypeParameter, DartType>{};
|
| + for (int i = 0; i < result.typeParameters.length; i++) {
|
| + substitution[result.typeParameters[i]] = arguments[i];
|
| + }
|
| + return substitute(result.withoutTypeParameters, substitution);
|
| + }
|
| }
|
|
|