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 1d3c0dbe59ce66950dcc499a772c29d79ee4f80f..0abc72018f0dd870f4f7d94aa90fa66d2a7f172f 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 |
@@ -17,70 +17,72 @@ import 'package:kernel/type_algebra.dart' show substitute; |
import 'kernel_builder.dart' |
show |
- FormalParameterBuilder, |
FunctionTypeAliasBuilder, |
+ KernelFunctionTypeBuilder, |
KernelTypeBuilder, |
+ KernelTypeVariableBuilder, |
LibraryBuilder, |
MetadataBuilder, |
TypeVariableBuilder, |
computeDefaultTypeArguments; |
-import 'kernel_function_type_builder.dart' show buildFunctionType; |
- |
class KernelFunctionTypeAliasBuilder |
- extends FunctionTypeAliasBuilder<KernelTypeBuilder, DartType> { |
+ extends FunctionTypeAliasBuilder<KernelFunctionTypeBuilder, DartType> { |
final Typedef target; |
DartType thisType; |
KernelFunctionTypeAliasBuilder( |
List<MetadataBuilder> metadata, |
- KernelTypeBuilder returnType, |
String name, |
List<TypeVariableBuilder> typeVariables, |
- List<FormalParameterBuilder> formals, |
+ KernelFunctionTypeBuilder type, |
LibraryBuilder parent, |
int charOffset, |
[Typedef target]) |
: target = target ?? |
(new Typedef(name, null, fileUri: parent.target.fileUri) |
..fileOffset = charOffset), |
- super(metadata, returnType, name, typeVariables, formals, parent, |
- charOffset); |
+ super(metadata, name, typeVariables, type, parent, charOffset); |
Typedef build(LibraryBuilder libraryBuilder) { |
- // TODO(ahe): We need to move type parameters from [thisType] to [target]. |
return target..type ??= buildThisType(libraryBuilder); |
} |
DartType buildThisType(LibraryBuilder library) { |
if (thisType != null) { |
- if (thisType == const InvalidType()) { |
- thisType = const DynamicType(); |
+ if (const InvalidType() == thisType) { |
library.addCompileTimeError( |
charOffset, "The typedef '$name' has a reference to itself."); |
+ return const DynamicType(); |
} |
return thisType; |
} |
thisType = const InvalidType(); |
- return thisType = |
- buildFunctionType(library, returnType, typeVariables, formals); |
+ DartType builtType = type?.build(library) ?? const DynamicType(); |
ahe
2017/07/05 07:55:23
These tests were crashing without handling type be
Johnni Winther
2017/07/05 10:35:57
Shouldn't the type be const InvalidType() is type
ahe
2017/07/05 11:11:32
The short answer is no, the longer answer is:
For
|
+ if (typeVariables != null) { |
+ for (KernelTypeVariableBuilder tv in typeVariables) { |
+ tv.parameter.bound = tv?.bound?.build(library); |
+ target.typeParameters.add(tv.parameter..parent = target); |
+ } |
+ } |
+ return thisType = builtType; |
} |
/// [arguments] have already been built. |
DartType buildTypesWithBuiltArguments( |
LibraryBuilder library, List<DartType> arguments) { |
var thisType = buildThisType(library); |
- if (thisType is DynamicType) return thisType; |
+ if (const DynamicType() == thisType) return thisType; |
FunctionType result = thisType; |
- if (result.typeParameters.isEmpty && arguments == null) return result; |
+ if (target.typeParameters.isEmpty && arguments == null) return result; |
arguments = |
- computeDefaultTypeArguments(library, result.typeParameters, arguments); |
+ computeDefaultTypeArguments(library, target.typeParameters, arguments); |
Map<TypeParameter, DartType> substitution = <TypeParameter, DartType>{}; |
- for (int i = 0; i < result.typeParameters.length; i++) { |
- substitution[result.typeParameters[i]] = arguments[i]; |
+ for (int i = 0; i < target.typeParameters.length; i++) { |
+ substitution[target.typeParameters[i]] = arguments[i]; |
} |
- return substitute(result.withoutTypeParameters, substitution); |
+ return substitute(result, substitution); |
} |
@override |
@@ -89,7 +91,7 @@ class KernelFunctionTypeAliasBuilder |
var thisType = buildThisType(library); |
if (thisType is DynamicType) return thisType; |
FunctionType result = thisType; |
- if (result.typeParameters.isEmpty && arguments == null) return result; |
+ if (target.typeParameters.isEmpty && arguments == null) return result; |
// Otherwise, substitute. |
List<DartType> builtArguments = <DartType>[]; |
if (arguments != null) { |