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/type_inference/type_inference_engine.dart'; | 6 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart'; |
7 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; | 7 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; |
8 import 'package:front_end/src/fasta/type_inference/type_schema_environment.dart'
; | 8 import 'package:front_end/src/fasta/type_inference/type_schema_environment.dart'
; |
9 import 'package:kernel/ast.dart' | 9 import 'package:kernel/ast.dart' |
10 show DartType, DynamicType, InterfaceType, Member; | 10 show DartType, DynamicType, InterfaceType, Member; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 236 } |
237 | 237 |
238 /// Performs the core type inference algorithm for string literals. | 238 /// Performs the core type inference algorithm for string literals. |
239 /// | 239 /// |
240 /// [typeContext], [typeNeeded], and the return value behave as described in | 240 /// [typeContext], [typeNeeded], and the return value behave as described in |
241 /// [inferExpression]. | 241 /// [inferExpression]. |
242 DartType inferStringLiteral(DartType typeContext, bool typeNeeded) { | 242 DartType inferStringLiteral(DartType typeContext, bool typeNeeded) { |
243 return typeNeeded ? coreTypes.stringClass.rawType : null; | 243 return typeNeeded ? coreTypes.stringClass.rawType : null; |
244 } | 244 } |
245 | 245 |
| 246 /// Performs the core type inference algorithm for string concatenations. |
| 247 /// |
| 248 /// [typeContext], [typeNeeded], and the return value behave as described in |
| 249 /// [inferExpression]. |
| 250 DartType inferStringConcatenation( |
| 251 DartType typeContext, bool typeNeeded, Iterable<E> expressions) { |
| 252 for (E expression in expressions) { |
| 253 inferExpression(expression, null, false); |
| 254 } |
| 255 return typeNeeded ? coreTypes.stringClass.rawType : null; |
| 256 } |
| 257 |
246 /// Performs the core type inference algorithm for variable declarations. | 258 /// Performs the core type inference algorithm for variable declarations. |
247 /// | 259 /// |
248 /// [declaredType] is the declared type of the variable, or `null` if the type | 260 /// [declaredType] is the declared type of the variable, or `null` if the type |
249 /// should be inferred. [initializer] is the initializer expression. | 261 /// should be inferred. [initializer] is the initializer expression. |
250 /// [offset] is the character offset of the variable declaration (for | 262 /// [offset] is the character offset of the variable declaration (for |
251 /// instrumentation). [setType] is a callback that will be used to set the | 263 /// instrumentation). [setType] is a callback that will be used to set the |
252 /// inferred type. | 264 /// inferred type. |
253 void inferVariableDeclaration(DartType declaredType, E initializer, | 265 void inferVariableDeclaration(DartType declaredType, E initializer, |
254 int offset, void setType(DartType type)) { | 266 int offset, void setType(DartType type)) { |
255 if (initializer == null) return; | 267 if (initializer == null) return; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 /// Gets the return type that was inferred for the current closure. | 313 /// Gets the return type that was inferred for the current closure. |
302 get inferredReturnType { | 314 get inferredReturnType { |
303 if (_inferredReturnType == null) { | 315 if (_inferredReturnType == null) { |
304 // No return statement found. | 316 // No return statement found. |
305 // TODO(paulberry): is it correct to infer `dynamic`? | 317 // TODO(paulberry): is it correct to infer `dynamic`? |
306 return const DynamicType(); | 318 return const DynamicType(); |
307 } | 319 } |
308 return _inferredReturnType; | 320 return _inferredReturnType; |
309 } | 321 } |
310 } | 322 } |
OLD | NEW |