private void checkFunction( JetDeclarationWithBody function, final @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(); }
private void resolveFunctionBody( @NotNull BindingTrace trace, @NotNull JetDeclarationWithBody function, @NotNull FunctionDescriptor functionDescriptor, @NotNull JetScope declaringScope) { if (!context.completeAnalysisNeeded(function)) return; JetExpression bodyExpression = function.getBodyExpression(); JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(declaringScope, functionDescriptor, trace); if (bodyExpression != null) { expressionTypingServices.checkFunctionReturnType( functionInnerScope, function, functionDescriptor, trace); } List<JetParameter> valueParameters = function.getValueParameters(); List<ValueParameterDescriptor> valueParameterDescriptors = functionDescriptor.getValueParameters(); checkDefaultParameterValues(valueParameters, valueParameterDescriptors, functionInnerScope); assert functionDescriptor.getReturnType() != null; }
@Override public void doGenerateBody( @NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) { codegen.returnExpression(declaration.getBodyExpression()); }