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

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

Issue 2895063003: Flatten futures when inferring the type of an async function expression. (Closed)
Patch Set: Don't recurse on future-derived types 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
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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (isExpressionFunction && 313 if (isExpressionFunction &&
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) {
324 return new InterfaceType(coreTypes.futureClass,
325 <DartType>[typeSchemaEnvironment.flattenFutures(type)]);
326 }
327
323 DartType wrapType(DartType type, Class class_) { 328 DartType wrapType(DartType type, Class class_) {
324 return new InterfaceType(class_, <DartType>[type]); 329 return new InterfaceType(class_, <DartType>[type]);
325 } 330 }
326 331
327 void _forEachArgument( 332 void _forEachArgument(
328 Arguments arguments, void callback(String name, Expression expression)) { 333 Arguments arguments, void callback(String name, Expression expression)) {
329 for (var expression in arguments.positional) { 334 for (var expression in arguments.positional) {
330 callback(null, expression); 335 callback(null, expression);
331 } 336 }
332 for (var namedExpression in arguments.named) { 337 for (var namedExpression in arguments.named) {
333 callback(namedExpression.name, namedExpression.value); 338 callback(namedExpression.name, namedExpression.value);
334 } 339 }
335 } 340 }
336 } 341 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698