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 if (analyzedElement.isGenerativeConstructor && cls.isAbstract) { | 650 returnType = types.nonNullExact(cls); |
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 } | |
663 } else { | 651 } else { |
664 signature.forEachParameter((LocalParameterElement element) { | 652 signature.forEachParameter((LocalParameterElement element) { |
665 locals.update(element, inferrer.typeOfElement(element), node); | 653 locals.update(element, inferrer.typeOfElement(element), node); |
666 }); | 654 }); |
667 visit(node.body); | 655 visit(node.body); |
668 switch (function.asyncMarker) { | 656 switch (function.asyncMarker) { |
669 case AsyncMarker.SYNC: | 657 case AsyncMarker.SYNC: |
670 if (returnType == null) { | 658 if (returnType == null) { |
671 // No return in the body. | 659 // No return in the body. |
672 returnType = locals.seenReturnOrThrow | 660 returnType = locals.seenReturnOrThrow |
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2341 TypeMask moveNextMask = elements.getMoveNextTypeMask(node); | 2329 TypeMask moveNextMask = elements.getMoveNextTypeMask(node); |
2342 | 2330 |
2343 T iteratorType = handleDynamicSend( | 2331 T iteratorType = handleDynamicSend( |
2344 node, iteratorSelector, iteratorMask, expressionType, | 2332 node, iteratorSelector, iteratorMask, expressionType, |
2345 new ArgumentsTypes<T>.empty()); | 2333 new ArgumentsTypes<T>.empty()); |
2346 | 2334 |
2347 return handleForInLoop(node, iteratorType, currentSelector, currentMask, | 2335 return handleForInLoop(node, iteratorType, currentSelector, currentMask, |
2348 moveNextSelector, moveNextMask); | 2336 moveNextSelector, moveNextMask); |
2349 } | 2337 } |
2350 } | 2338 } |
OLD | NEW |