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 simple_types_inferrer; | 5 library simple_types_inferrer; |
6 | 6 |
7 import '../closure.dart' show | 7 import '../closure.dart' show |
8 ClosureClassMap, | 8 ClosureClassMap, |
9 ClosureScope; | 9 ClosureScope; |
10 import '../common.dart'; | 10 import '../common.dart'; |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 // fields that we haven't initialized for sure. | 640 // fields that we haven't initialized for sure. |
641 cls.forEachInstanceField((_, FieldElement field) { | 641 cls.forEachInstanceField((_, FieldElement field) { |
642 if (field.isFinal) return; | 642 if (field.isFinal) return; |
643 T type = locals.fieldScope.readField(field); | 643 T type = locals.fieldScope.readField(field); |
644 if (type == null && field.initializer == null) { | 644 if (type == null && field.initializer == null) { |
645 inferrer.recordTypeOfNonFinalField( | 645 inferrer.recordTypeOfNonFinalField( |
646 spannable, field, types.nullType); | 646 spannable, field, types.nullType); |
647 } | 647 } |
648 }); | 648 }); |
649 } | 649 } |
650 returnType = types.nonNullExact(cls); | 650 if (analyzedElement.isGenerativeConstructor && cls.isAbstract) { |
| 651 if (compiler.world.isDirectlyInstantiated(cls)) { |
| 652 returnType = types.nonNullExact(cls); |
| 653 } else if (compiler.world.isIndirectlyInstantiated(cls)) { |
| 654 returnType = types.nonNullSubclass(cls); |
| 655 } else { |
| 656 // TODO(johnniwinther): Avoid analyzing [analyzedElement] in this |
| 657 // case; it's never called. |
| 658 returnType = types.nonNullEmpty(); |
| 659 } |
| 660 } else { |
| 661 returnType = types.nonNullExact(cls); |
| 662 } |
651 } else { | 663 } else { |
652 signature.forEachParameter((LocalParameterElement element) { | 664 signature.forEachParameter((LocalParameterElement element) { |
653 locals.update(element, inferrer.typeOfElement(element), node); | 665 locals.update(element, inferrer.typeOfElement(element), node); |
654 }); | 666 }); |
655 visit(node.body); | 667 visit(node.body); |
656 switch (function.asyncMarker) { | 668 switch (function.asyncMarker) { |
657 case AsyncMarker.SYNC: | 669 case AsyncMarker.SYNC: |
658 if (returnType == null) { | 670 if (returnType == null) { |
659 // No return in the body. | 671 // No return in the body. |
660 returnType = locals.seenReturnOrThrow | 672 returnType = locals.seenReturnOrThrow |
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2329 TypeMask moveNextMask = elements.getMoveNextTypeMask(node); | 2341 TypeMask moveNextMask = elements.getMoveNextTypeMask(node); |
2330 | 2342 |
2331 T iteratorType = handleDynamicSend( | 2343 T iteratorType = handleDynamicSend( |
2332 node, iteratorSelector, iteratorMask, expressionType, | 2344 node, iteratorSelector, iteratorMask, expressionType, |
2333 new ArgumentsTypes<T>.empty()); | 2345 new ArgumentsTypes<T>.empty()); |
2334 | 2346 |
2335 return handleForInLoop(node, iteratorType, currentSelector, currentMask, | 2347 return handleForInLoop(node, iteratorType, currentSelector, currentMask, |
2336 moveNextSelector, moveNextMask); | 2348 moveNextSelector, moveNextMask); |
2337 } | 2349 } |
2338 } | 2350 } |
OLD | NEW |