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

Side by Side Diff: pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart

Issue 2892593005: Handle FutureOr type when inferring async closures. (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 import 'package:front_end/src/base/instrumentation.dart'; 5 import 'package:front_end/src/base/instrumentation.dart';
6 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'; 6 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart';
7 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart'; 7 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart';
8 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart' ; 8 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart' ;
9 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; 9 import 'package:front_end/src/fasta/type_inference/type_promotion.dart';
10 import 'package:front_end/src/fasta/type_inference/type_schema.dart'; 10 import 'package:front_end/src/fasta/type_inference/type_schema.dart';
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 returnType is InterfaceType && 314 returnType is InterfaceType &&
315 identical(returnType.classNode, coreTypes.nullClass)) { 315 identical(returnType.classNode, coreTypes.nullClass)) {
316 // Analyzer coerces `Null` to `dynamic` in expression functions; the spec 316 // Analyzer coerces `Null` to `dynamic` in expression functions; the spec
317 // doesn't say to do this. TODO(paulberry): resolve this difference. 317 // doesn't say to do this. TODO(paulberry): resolve this difference.
318 return const DynamicType(); 318 return const DynamicType();
319 } 319 }
320 return returnType; 320 return returnType;
321 } 321 }
322 322
323 DartType wrapFutureType(DartType type) { 323 DartType wrapFutureType(DartType type) {
324 var typeWithoutFutureOr = type;
325 if (type is InterfaceType &&
326 identical(type.classNode, coreTypes.futureOrClass)) {
327 typeWithoutFutureOr = type.typeArguments[0];
328 }
324 return new InterfaceType(coreTypes.futureClass, 329 return new InterfaceType(coreTypes.futureClass,
325 <DartType>[typeSchemaEnvironment.flattenFutures(type)]); 330 <DartType>[typeSchemaEnvironment.flattenFutures(typeWithoutFutureOr)]);
326 } 331 }
327 332
328 DartType wrapType(DartType type, Class class_) { 333 DartType wrapType(DartType type, Class class_) {
329 return new InterfaceType(class_, <DartType>[type]); 334 return new InterfaceType(class_, <DartType>[type]);
330 } 335 }
331 336
332 void _forEachArgument( 337 void _forEachArgument(
333 Arguments arguments, void callback(String name, Expression expression)) { 338 Arguments arguments, void callback(String name, Expression expression)) {
334 for (var expression in arguments.positional) { 339 for (var expression in arguments.positional) {
335 callback(null, expression); 340 callback(null, expression);
336 } 341 }
337 for (var namedExpression in arguments.named) { 342 for (var namedExpression in arguments.named) {
338 callback(namedExpression.name, namedExpression.value); 343 callback(namedExpression.name, namedExpression.value);
339 } 344 }
340 } 345 }
341 } 346 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698