Add gsharing support for cached casts.