OLD | NEW |
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/errors.dart' show internalError; | 6 import 'package:front_end/src/fasta/errors.dart' show internalError; |
7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'; | 7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'; |
8 import 'package:front_end/src/fasta/names.dart' show callName; | 8 import 'package:front_end/src/fasta/names.dart' show callName; |
9 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart'; | 9 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart'; |
10 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart'
; | 10 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart'
; |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 substitution = | 584 substitution = |
585 Substitution.fromPairs(calleeTypeParameters, explicitTypeArguments); | 585 Substitution.fromPairs(calleeTypeParameters, explicitTypeArguments); |
586 } else if (calleeTypeParameters.length != 0) { | 586 } else if (calleeTypeParameters.length != 0) { |
587 substitution = Substitution.fromPairs( | 587 substitution = Substitution.fromPairs( |
588 calleeTypeParameters, | 588 calleeTypeParameters, |
589 new List<DartType>.filled( | 589 new List<DartType>.filled( |
590 calleeTypeParameters.length, const DynamicType())); | 590 calleeTypeParameters.length, const DynamicType())); |
591 } | 591 } |
592 // TODO(paulberry): if we are doing top level inference and type arguments | 592 // TODO(paulberry): if we are doing top level inference and type arguments |
593 // were omitted, report an error. | 593 // were omitted, report an error. |
594 if (!isTopLevel || isOverloadedArithmeticOperator) { | 594 if (!isTopLevel || |
| 595 isOverloadedArithmeticOperator || |
| 596 TypeInferenceEngineImpl.expandedTopLevelInference) { |
595 int i = 0; | 597 int i = 0; |
596 _forEachArgument(arguments, (name, expression) { | 598 _forEachArgument(arguments, (name, expression) { |
597 DartType formalType = name != null | 599 DartType formalType = name != null |
598 ? getNamedParameterType(calleeType, name) | 600 ? getNamedParameterType(calleeType, name) |
599 : getPositionalParameterType(calleeType, i++); | 601 : getPositionalParameterType(calleeType, i++); |
600 DartType inferredFormalType = substitution != null | 602 DartType inferredFormalType = substitution != null |
601 ? substitution.substituteType(formalType) | 603 ? substitution.substituteType(formalType) |
602 : formalType; | 604 : formalType; |
603 var expressionType = inferExpression( | 605 var expressionType = inferExpression( |
604 expression, | 606 expression, |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 void _forEachArgument( | 947 void _forEachArgument( |
946 Arguments arguments, void callback(String name, Expression expression)) { | 948 Arguments arguments, void callback(String name, Expression expression)) { |
947 for (var expression in arguments.positional) { | 949 for (var expression in arguments.positional) { |
948 callback(null, expression); | 950 callback(null, expression); |
949 } | 951 } |
950 for (var namedExpression in arguments.named) { | 952 for (var namedExpression in arguments.named) { |
951 callback(namedExpression.name, namedExpression.value); | 953 callback(namedExpression.name, namedExpression.value); |
952 } | 954 } |
953 } | 955 } |
954 } | 956 } |
OLD | NEW |