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 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 T visitClosureTypeInformation(ClosureTypeInformation info); | 1746 T visitClosureTypeInformation(ClosureTypeInformation info); |
1747 T visitAwaitTypeInformation(AwaitTypeInformation info); | 1747 T visitAwaitTypeInformation(AwaitTypeInformation info); |
1748 T visitYieldTypeInformation(YieldTypeInformation info); | 1748 T visitYieldTypeInformation(YieldTypeInformation info); |
1749 } | 1749 } |
1750 | 1750 |
1751 TypeMask _narrowType( | 1751 TypeMask _narrowType( |
1752 ClosedWorld closedWorld, TypeMask type, ResolutionDartType annotation, | 1752 ClosedWorld closedWorld, TypeMask type, ResolutionDartType annotation, |
1753 {bool isNullable: true}) { | 1753 {bool isNullable: true}) { |
1754 if (annotation.treatAsDynamic) return type; | 1754 if (annotation.treatAsDynamic) return type; |
1755 if (annotation.isObject) return type; | 1755 if (annotation.isObject) return type; |
| 1756 if (annotation.isVoid) return type; |
1756 TypeMask otherType; | 1757 TypeMask otherType; |
1757 if (annotation.isTypedef || annotation.isFunctionType) { | 1758 if (annotation.isTypedef || annotation.isFunctionType) { |
1758 otherType = closedWorld.commonMasks.functionType; | 1759 otherType = closedWorld.commonMasks.functionType; |
1759 } else if (annotation.isTypeVariable) { | 1760 } else if (annotation.isTypeVariable) { |
1760 // TODO(ngeoffray): Narrow to bound. | 1761 // TODO(ngeoffray): Narrow to bound. |
1761 return type; | 1762 return type; |
1762 } else if (annotation.isVoid) { | |
1763 otherType = closedWorld.commonMasks.nullType; | |
1764 } else { | 1763 } else { |
1765 ResolutionInterfaceType interfaceType = annotation; | 1764 ResolutionInterfaceType interfaceType = annotation; |
1766 otherType = new TypeMask.nonNullSubtype(interfaceType.element, closedWorld); | 1765 otherType = new TypeMask.nonNullSubtype(interfaceType.element, closedWorld); |
1767 } | 1766 } |
1768 if (isNullable) otherType = otherType.nullable(); | 1767 if (isNullable) otherType = otherType.nullable(); |
1769 if (type == null) return otherType; | 1768 if (type == null) return otherType; |
1770 return type.intersection(otherType, closedWorld); | 1769 return type.intersection(otherType, closedWorld); |
1771 } | 1770 } |
OLD | NEW |