diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java index 86c3700fa5c..c0e06521de1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java @@ -26,12 +26,14 @@ import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE; public class ControlFlowAnalyzer { private TopDownAnalysisContext context; private ExpressionTypingServices typeInferrerServices; - private final JetControlFlowDataTraceFactory flowDataTraceFactory; + private final JetControlFlowDataTraceFactory flowDataTraceFactory; + private final boolean declaredLocally; - public ControlFlowAnalyzer(TopDownAnalysisContext context, JetControlFlowDataTraceFactory flowDataTraceFactory) { + public ControlFlowAnalyzer(TopDownAnalysisContext context, JetControlFlowDataTraceFactory flowDataTraceFactory, boolean declaredLocally) { this.context = context; this.flowDataTraceFactory = flowDataTraceFactory; this.typeInferrerServices = context.getSemanticServices().getTypeInferrerServices(context.getTrace()); + this.declaredLocally = declaredLocally; } public void process() { @@ -60,9 +62,11 @@ public class ControlFlowAnalyzer { } private void checkFunction(JetDeclarationWithBody function, FunctionDescriptor functionDescriptor, final @NotNull JetType expectedReturnType) { + assert function instanceof JetDeclaration; + JetExpression bodyExpression = function.getBodyExpression(); if (bodyExpression == null) return; - JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider((JetElement) function, bodyExpression, flowDataTraceFactory, context.getTrace()); + JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider((JetDeclaration) function, bodyExpression, flowDataTraceFactory, context.getTrace()); final boolean blockBody = function.hasBlockBody(); List unreachableElements = Lists.newArrayList(); @@ -108,8 +112,9 @@ public class ControlFlowAnalyzer { } }); } - - //flowInformationProvider.markUninitializedVariables(function.asElement()); + if (!declaredLocally) { + flowInformationProvider.markUninitializedVariables(function.asElement()); + } } private void checkProperty(JetProperty property) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java index ca3b4d4148d..32755ce154c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java @@ -55,16 +55,17 @@ public class TopDownAnalyzer { public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) { return ClassObjectStatus.NOT_ALLOWED; } - }, Collections.singletonList(object), JetControlFlowDataTraceFactory.EMPTY); + }, Collections.singletonList(object), JetControlFlowDataTraceFactory.EMPTY, true); } - public static void process( + private static void process( @NotNull JetSemanticServices semanticServices, @NotNull BindingTrace trace, @NotNull JetScope outerScope, NamespaceLike owner, @NotNull List declarations, - @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) { + @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory, + boolean declaredLocally) { TopDownAnalysisContext context = new TopDownAnalysisContext(semanticServices, trace); new TypeHierarchyResolver(context).process(outerScope, owner, declarations); new DeclarationResolver(context).process(); @@ -72,7 +73,17 @@ public class TopDownAnalyzer { new OverrideResolver(context).process(); new BodyResolver(context).resolveBehaviorDeclarationBodies(); new DeclarationsChecker(context).process(); - new ControlFlowAnalyzer(context, flowDataTraceFactory).process(); + new ControlFlowAnalyzer(context, flowDataTraceFactory, declaredLocally).process(); + } + + public static void process( + @NotNull JetSemanticServices semanticServices, + @NotNull BindingTrace trace, + @NotNull JetScope outerScope, + NamespaceLike owner, + @NotNull List declarations, + @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) { + process(semanticServices, trace, outerScope, owner, declarations, flowDataTraceFactory, false); } public static void processStandardLibraryNamespace(