Fixed NPE when dealing with union and identityref types.