| Index: pkg/front_end/lib/src/fasta/type_inference/local_type_inferrer.dart
|
| diff --git a/pkg/front_end/lib/src/fasta/type_inference/local_type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/local_type_inferrer.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b35a41cb8b2f23816e9371748f94d65cc24452c4
|
| --- /dev/null
|
| +++ b/pkg/front_end/lib/src/fasta/type_inference/local_type_inferrer.dart
|
| @@ -0,0 +1,52 @@
|
| +import 'package:kernel/ast.dart' show DartType;
|
| +import 'package:kernel/core_types.dart';
|
| +
|
| +import '../builder/shadow_ast.dart';
|
| +
|
| +class FunctionContext {
|
| + final LocalTypeInferrer inferrer;
|
| +
|
| + final bool returnTypeNeeded;
|
| +
|
| + final bool isAsync;
|
| +
|
| + final bool isGenerator;
|
| +
|
| + DartType _inferredReturnType;
|
| +
|
| + FunctionContext(
|
| + this.inferrer, this.returnTypeNeeded, this.isAsync, this.isGenerator);
|
| +
|
| + get inferredReturnType {
|
| + if (_inferredReturnType == null) {
|
| + // No return statement found.
|
| + throw new UnimplementedError();
|
| + }
|
| + return _inferredReturnType;
|
| + }
|
| +
|
| + void recordReturnType(DartType type) {
|
| + _inferredReturnType = inferrer.union(_inferredReturnType, type);
|
| + }
|
| +}
|
| +
|
| +class LocalTypeInferrer {
|
| + final CoreTypes coreTypes;
|
| +
|
| + LocalTypeInferrer(this.coreTypes);
|
| +
|
| + void finishVariableDeclaration(DartType type, ShadowExpression initializer,
|
| + ShadowVariableDeclaration variable) {
|
| + // TODO(paulberry): is this needed at all?
|
| + // throw new UnimplementedError();
|
| + }
|
| +
|
| + void inferBody(ShadowStatement statement) {
|
| + statement.shadowInfer(this, null);
|
| + }
|
| +
|
| + DartType union(DartType a, DartType b) {
|
| + if (a == null) return b;
|
| + throw new UnimplementedError();
|
| + }
|
| +}
|
|
|