public static void TryToCastReturnStatement(ReturnStatement returnStatement) { TypeResolver.ReportErrors = false; MethodDeclaration method = (MethodDeclaration)returnStatement.GetParentByType(typeof(MethodDeclaration)); if (!returnStatement.IsVoidReturn) { TryToCastExpression(returnStatement.ReturnBody, method.ReturnType); } }
public static void ResolveReturnStatementType(ReturnStatement returnStatement) { TypeCaster.TryToCastReturnStatement(returnStatement); ReportErrors = true; MethodDeclaration method = (MethodDeclaration)returnStatement.GetParentByType(typeof(MethodDeclaration)); if (returnStatement.IsVoidReturn && method.ReturnType is Void) { return; } InnerType returnStatementType = ResolveExpressionType(returnStatement.ReturnBody); if (method.ReturnType != returnStatementType) { ReportError(new IncompatibleReturnType(method.Name, method.ReturnType, returnStatementType, returnStatement.SourceContext)); } }