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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import '../common.dart'; | 5 import '../common.dart'; |
6 import '../elements/elements.dart'; | 6 import '../elements/elements.dart'; |
7 import '../elements/entities.dart'; | 7 import '../elements/entities.dart'; |
8 import '../elements/types.dart'; | 8 import '../elements/types.dart'; |
9 import '../tree/nodes.dart' as ast; | 9 import '../tree/nodes.dart' as ast; |
10 import '../types/masks.dart'; | 10 import '../types/masks.dart'; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 338 |
339 ParameterTypeInformation getInferredTypeOfParameter( | 339 ParameterTypeInformation getInferredTypeOfParameter( |
340 ParameterElement parameter) { | 340 ParameterElement parameter) { |
341 parameter = parameter.implementation; | 341 parameter = parameter.implementation; |
342 | 342 |
343 ParameterTypeInformation createTypeInformation() { | 343 ParameterTypeInformation createTypeInformation() { |
344 if (parameter.functionDeclaration.isLocal) { | 344 if (parameter.functionDeclaration.isLocal) { |
345 LocalFunctionElement localFunction = parameter.functionDeclaration; | 345 LocalFunctionElement localFunction = parameter.functionDeclaration; |
346 MethodElement callMethod = localFunction.callMethod; | 346 MethodElement callMethod = localFunction.callMethod; |
347 return new ParameterTypeInformation.localFunction( | 347 return new ParameterTypeInformation.localFunction( |
348 getInferredTypeOfMember(callMethod), parameter, callMethod); | 348 getInferredTypeOfMember(callMethod), |
| 349 parameter, |
| 350 parameter.type, |
| 351 callMethod); |
349 } else if (parameter.functionDeclaration.isInstanceMember) { | 352 } else if (parameter.functionDeclaration.isInstanceMember) { |
350 MethodElement method = parameter.functionDeclaration; | 353 MethodElement method = parameter.functionDeclaration; |
351 return new ParameterTypeInformation.instanceMember( | 354 return new ParameterTypeInformation.instanceMember( |
352 getInferredTypeOfMember(method), | 355 getInferredTypeOfMember(method), |
353 parameter, | 356 parameter, |
| 357 parameter.type, |
354 method, | 358 method, |
355 new ParameterAssignments()); | 359 new ParameterAssignments()); |
356 } else { | 360 } else { |
357 MethodElement method = parameter.functionDeclaration; | 361 MethodElement method = parameter.functionDeclaration; |
358 return new ParameterTypeInformation.static( | 362 return new ParameterTypeInformation.static( |
359 getInferredTypeOfMember(method), parameter, method); | 363 getInferredTypeOfMember(method), parameter, parameter.type, method, |
| 364 // TODO(johnniwinther): Is this still valid now that initializing |
| 365 // formals also introduce locals? |
| 366 isInitializingFormal: parameter.isInitializingFormal); |
360 } | 367 } |
361 } | 368 } |
362 | 369 |
363 return parameterTypeInformations.putIfAbsent(parameter, () { | 370 return parameterTypeInformations.putIfAbsent(parameter, () { |
364 ParameterTypeInformation typeInformation = createTypeInformation(); | 371 ParameterTypeInformation typeInformation = createTypeInformation(); |
365 _orderedTypeInformations.add(typeInformation); | 372 _orderedTypeInformations.add(typeInformation); |
366 return typeInformation; | 373 return typeInformation; |
367 }); | 374 }); |
368 } | 375 } |
369 | 376 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 TypeMask newType = null; | 631 TypeMask newType = null; |
625 for (TypeMask mask in list) { | 632 for (TypeMask mask in list) { |
626 newType = newType == null ? mask : newType.union(mask, closedWorld); | 633 newType = newType == null ? mask : newType.union(mask, closedWorld); |
627 // Likewise - stop early if we already reach dynamic. | 634 // Likewise - stop early if we already reach dynamic. |
628 if (newType.containsAll(closedWorld)) return dynamicType; | 635 if (newType.containsAll(closedWorld)) return dynamicType; |
629 } | 636 } |
630 | 637 |
631 return newType ?? const TypeMask.nonNullEmpty(); | 638 return newType ?? const TypeMask.nonNullEmpty(); |
632 } | 639 } |
633 } | 640 } |
OLD | NEW |