Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: pkg/compiler/lib/src/inferrer/builder.dart

Issue 2799763003: Fix for type analysis bug in constructor with early return (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/locals_handler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ClosureClassMap; 7 import '../closure.dart' show ClosureClassMap;
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/names.dart' show Identifiers, Selectors; 9 import '../common/names.dart' show Identifiers, Selectors;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ? locals.fieldScope.isThisExposed 124 ? locals.fieldScope.isThisExposed
125 : true; 125 : true;
126 } 126 }
127 127
128 void set isThisExposed(value) { 128 void set isThisExposed(value) {
129 if (analyzedElement.isGenerativeConstructor) { 129 if (analyzedElement.isGenerativeConstructor) {
130 locals.fieldScope.isThisExposed = value; 130 locals.fieldScope.isThisExposed = value;
131 } 131 }
132 } 132 }
133 133
134 void initializationIsIndefinite() {
135 if (analyzedElement.isGenerativeConstructor) {
136 locals.fieldScope.isIndefinite = true;
137 }
138 }
139
134 DiagnosticReporter get reporter => compiler.reporter; 140 DiagnosticReporter get reporter => compiler.reporter;
135 141
136 ClosedWorld get closedWorld => inferrer.closedWorld; 142 ClosedWorld get closedWorld => inferrer.closedWorld;
137 143
138 @override 144 @override
139 SemanticSendVisitor get sendVisitor => this; 145 SemanticSendVisitor get sendVisitor => this;
140 146
141 @override 147 @override
142 TypeInformation apply(ast.Node node, _) => visit(node); 148 TypeInformation apply(ast.Node node, _) => visit(node);
143 149
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 handleCondition(node.condition, tests); 709 handleCondition(node.condition, tests);
704 updateIsChecks(tests, usePositive: true); 710 updateIsChecks(tests, usePositive: true);
705 visit(node.body); 711 visit(node.body);
706 visit(node.update); 712 visit(node.update);
707 }); 713 });
708 } 714 }
709 715
710 TypeInformation visitTryStatement(ast.TryStatement node) { 716 TypeInformation visitTryStatement(ast.TryStatement node) {
711 LocalsHandler saved = locals; 717 LocalsHandler saved = locals;
712 locals = new LocalsHandler.from(locals, node, useOtherTryBlock: false); 718 locals = new LocalsHandler.from(locals, node, useOtherTryBlock: false);
719 initializationIsIndefinite();
713 visit(node.tryBlock); 720 visit(node.tryBlock);
714 saved.mergeDiamondFlow(locals, null); 721 saved.mergeDiamondFlow(locals, null);
715 locals = saved; 722 locals = saved;
716 for (ast.Node catchBlock in node.catchBlocks) { 723 for (ast.Node catchBlock in node.catchBlocks) {
717 saved = locals; 724 saved = locals;
718 locals = new LocalsHandler.from(locals, catchBlock); 725 locals = new LocalsHandler.from(locals, catchBlock);
719 visit(catchBlock); 726 visit(catchBlock);
720 saved.mergeDiamondFlow(locals, null); 727 saved.mergeDiamondFlow(locals, null);
721 locals = saved; 728 locals = saved;
722 } 729 }
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 } 2863 }
2857 locals.seenReturnOrThrow = true; 2864 locals.seenReturnOrThrow = true;
2858 return null; 2865 return null;
2859 } 2866 }
2860 2867
2861 TypeInformation visitReturn(ast.Return node) { 2868 TypeInformation visitReturn(ast.Return node) {
2862 ast.Node expression = node.expression; 2869 ast.Node expression = node.expression;
2863 recordReturnType( 2870 recordReturnType(
2864 expression == null ? types.nullType : expression.accept(this)); 2871 expression == null ? types.nullType : expression.accept(this));
2865 locals.seenReturnOrThrow = true; 2872 locals.seenReturnOrThrow = true;
2873 initializationIsIndefinite();
2866 return null; 2874 return null;
2867 } 2875 }
2868 2876
2869 TypeInformation handleForInLoop( 2877 TypeInformation handleForInLoop(
2870 ast.ForIn node, 2878 ast.ForIn node,
2871 TypeInformation iteratorType, 2879 TypeInformation iteratorType,
2872 Selector currentSelector, 2880 Selector currentSelector,
2873 TypeMask currentMask, 2881 TypeMask currentMask,
2874 Selector moveNextSelector, 2882 Selector moveNextSelector,
2875 TypeMask moveNextMask) { 2883 TypeMask moveNextMask) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2931 Selector moveNextSelector = Selectors.moveNext; 2939 Selector moveNextSelector = Selectors.moveNext;
2932 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node); 2940 TypeMask moveNextMask = inTreeData.typeOfIteratorMoveNext(node);
2933 2941
2934 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector, 2942 TypeInformation iteratorType = handleDynamicSend(node, iteratorSelector,
2935 iteratorMask, expressionType, new ArgumentsTypes.empty()); 2943 iteratorMask, expressionType, new ArgumentsTypes.empty());
2936 2944
2937 return handleForInLoop(node, iteratorType, currentSelector, currentMask, 2945 return handleForInLoop(node, iteratorType, currentSelector, currentMask,
2938 moveNextSelector, moveNextMask); 2946 moveNextSelector, moveNextMask);
2939 } 2947 }
2940 } 2948 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/locals_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698