Can contrastive learning avoid shortcut solutions?