diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java index fe059ae6b90..e781b0b2712 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java @@ -74,6 +74,30 @@ public class JetFlowInformationProvider { return pseudocodeVariablesData; } + public void checkFunction( + @NotNull JetDeclarationWithBody function, + @NotNull JetType expectedReturnType, + boolean isLocalObject + ) { + boolean isPropertyAccessor = function instanceof JetPropertyAccessor; + if (!isPropertyAccessor) { + recordInitializedVariables(); + } + + if (isLocalObject) return; + + checkDefiniteReturn(expectedReturnType); + + if (!isPropertyAccessor) { + // Property accessor is checked through initialization of a class/object or package properties (at 'checkDeclarationContainer') + markUninitializedVariables(); + } + + markUnusedVariables(); + + markUnusedLiteralsInBlock(); + } + private void collectReturnExpressions(@NotNull final Collection returnedExpressions) { final Set instructions = Sets.newHashSet(pseudocode.getInstructions()); SubroutineExitInstruction exitInstruction = pseudocode.getExitInstruction(); 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 8d5190faedc..8eb9f2214aa 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java @@ -91,28 +91,9 @@ public class ControlFlowAnalyzer { } private void checkFunction(JetDeclarationWithBody function, @NotNull JetType expectedReturnType) { - assert function instanceof JetDeclaration; - JetExpression bodyExpression = function.getBodyExpression(); if (bodyExpression == null) return; - JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider((JetDeclaration) function, trace); - - boolean isPropertyAccessor = function instanceof JetPropertyAccessor; - if (!isPropertyAccessor) { - flowInformationProvider.recordInitializedVariables(); - } - - if (topDownAnalysisParameters.isDeclaredLocally()) return; - - flowInformationProvider.checkDefiniteReturn(expectedReturnType); - - if (!isPropertyAccessor) { - // Property accessor is checked through initialization of a class/object or package properties (at 'checkDeclarationContainer') - flowInformationProvider.markUninitializedVariables(); - } - - flowInformationProvider.markUnusedVariables(); - - flowInformationProvider.markUnusedLiteralsInBlock(); + JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider(function, trace); + flowInformationProvider.checkFunction(function, expectedReturnType, topDownAnalysisParameters.isDeclaredLocally()); } }