The effects of this depend to a significant extent on what kind of drink used to be there, and how much remained in the cask. Leaving a couple of litres of a single malt whisky in an old cask will certainly add pep to a beer, though whether this is any greater in quality or quantity than it would occur were the same amount simply poured into the beer from a bottle is unclear.
Doing the same with casks formerly used for wines, fortified or otherwise, is rather more hit-and-miss. If the lees of old wine remain in the cask when the beer is racked into it, the result can be uniquely vile. While there is some science behind the idea that a beer racked into a drained and dried wine cask will develop characteristics from the action of residual wine yeast lodged in its walls, it is not fully mastered.