| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library compiler.src.inferrer.type_graph_nodes; | 5 library compiler.src.inferrer.type_graph_nodes; |
| 6 | 6 |
| 7 import 'dart:collection' show IterableBase; | 7 import 'dart:collection' show IterableBase; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/names.dart' show Identifiers; | 10 import '../common/names.dart' show Identifiers; |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 // might not see all call-sites and thus miss the use of it. | 612 // might not see all call-sites and thus miss the use of it. |
| 613 TypeInformation defaultType = inferrer.getDefaultTypeOfParameter(element); | 613 TypeInformation defaultType = inferrer.getDefaultTypeOfParameter(element); |
| 614 if (defaultType != null) defaultType.addUser(this); | 614 if (defaultType != null) defaultType.addUser(this); |
| 615 } | 615 } |
| 616 | 616 |
| 617 // TODO(herhut): Cleanup into one conditional. | 617 // TODO(herhut): Cleanup into one conditional. |
| 618 TypeMask handleSpecialCases(InferrerEngine inferrer) { | 618 TypeMask handleSpecialCases(InferrerEngine inferrer) { |
| 619 if (!inferrer.backend.canFunctionParametersBeUsedForGlobalOptimizations( | 619 if (!inferrer.backend.canFunctionParametersBeUsedForGlobalOptimizations( |
| 620 element.functionDeclaration) || | 620 element.functionDeclaration) || |
| 621 inferrer.annotations.assumeDynamic(declaration)) { | 621 inferrer.annotations.assumeDynamic(declaration)) { |
| 622 // Do not infer types for parameters that have a correspondign annotation | 622 // Do not infer types for parameters that have a corresponding annotation |
| 623 // or that are assigned by synthesized calls. | 623 // or that are assigned by synthesized calls. |
| 624 giveUp(inferrer); | 624 giveUp(inferrer); |
| 625 return safeType(inferrer); | 625 return safeType(inferrer); |
| 626 } | 626 } |
| 627 | 627 |
| 628 // The below do not apply to parameters of constructors, so skip | 628 // The below do not apply to parameters of constructors, so skip |
| 629 // initializing formals. | 629 // initializing formals. |
| 630 if (element.isInitializingFormal) return null; | 630 if (element.isInitializingFormal) return null; |
| 631 | 631 |
| 632 if ((isTearOffClosureParameter || declaration.isLocal) && | 632 if ((isTearOffClosureParameter || declaration.isLocal) && |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 return 'Narrow to $typeAnnotation $type'; | 1301 return 'Narrow to $typeAnnotation $type'; |
| 1302 } | 1302 } |
| 1303 | 1303 |
| 1304 accept(TypeInformationVisitor visitor) { | 1304 accept(TypeInformationVisitor visitor) { |
| 1305 return visitor.visitNarrowTypeInformation(this); | 1305 return visitor.visitNarrowTypeInformation(this); |
| 1306 } | 1306 } |
| 1307 } | 1307 } |
| 1308 | 1308 |
| 1309 /** | 1309 /** |
| 1310 * An [InferredTypeInformation] is a [TypeInformation] that | 1310 * An [InferredTypeInformation] is a [TypeInformation] that |
| 1311 * defaults to the dynamic type until it is marked as beeing | 1311 * defaults to the dynamic type until it is marked as being |
| 1312 * inferred, at which point it computes its type based on | 1312 * inferred, at which point it computes its type based on |
| 1313 * its assignments. | 1313 * its assignments. |
| 1314 */ | 1314 */ |
| 1315 abstract class InferredTypeInformation extends TypeInformation { | 1315 abstract class InferredTypeInformation extends TypeInformation { |
| 1316 /** Whether the element type in that container has been inferred. */ | 1316 /** Whether the element type in that container has been inferred. */ |
| 1317 bool inferred = false; | 1317 bool inferred = false; |
| 1318 | 1318 |
| 1319 InferredTypeInformation( | 1319 InferredTypeInformation( |
| 1320 MemberTypeInformation context, TypeInformation parentType) | 1320 MemberTypeInformation context, TypeInformation parentType) |
| 1321 : super(context) { | 1321 : super(context) { |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 } else if (annotation.isVoid) { | 1762 } else if (annotation.isVoid) { |
| 1763 otherType = closedWorld.commonMasks.nullType; | 1763 otherType = closedWorld.commonMasks.nullType; |
| 1764 } else { | 1764 } else { |
| 1765 ResolutionInterfaceType interfaceType = annotation; | 1765 ResolutionInterfaceType interfaceType = annotation; |
| 1766 otherType = new TypeMask.nonNullSubtype(interfaceType.element, closedWorld); | 1766 otherType = new TypeMask.nonNullSubtype(interfaceType.element, closedWorld); |
| 1767 } | 1767 } |
| 1768 if (isNullable) otherType = otherType.nullable(); | 1768 if (isNullable) otherType = otherType.nullable(); |
| 1769 if (type == null) return otherType; | 1769 if (type == null) return otherType; |
| 1770 return type.intersection(otherType, closedWorld); | 1770 return type.intersection(otherType, closedWorld); |
| 1771 } | 1771 } |
| OLD | NEW |