In Inkscape I have two objects, a line and a shape. How to I achieve the effect on the right? If it is not possible with a line how do I do it with two shapes?
Make a copy of the blue shape. Use it as the clipping path for the red shape. Raise the copy to top, select both and goto Object > Clip > Set.
Why copy? Because the clipping path is invisible until released.
NOTE1: If you select your original blue shape and press Ctrl+D (=duplicate) the copy appears exactly at the right place and automatically on the top
NOTE2: Select the result and group it to keep the parts together.
NOTE3: The red shape can be a as well a line as a more complex shape. But groups can easily lead to troubles beacause one can accidentally edit a group regardles it's under a clipping path. That can result hard to select invisible parts.