How are duplicate call signs dealt with?
The scenario you're asking about is common.  Let's say that your Delta 158 from South Korea to Detroit is running several hours late, and the decision is made to operate the A320 DTW-BOS on time.  ATC doesn't accept having two aircraft flying with the same callsign at once due to exactly the sort of confusion you suggest, so something has to change.

What will happen is that the second flight -- i.e. the one that isn't already airborne, will get a new ATC callsign.  Sometimes you'll hear something like "Delta 158A" as the callsign of the flight, or they may use something entirely different like "Delta 9158" as the ATC callsign for that flight.  Each company will have their own method of resolving the conflict; some use letters, others don't.  Some can go to "9000 + original flight number," and others will simply use something like 9001 for the first "stubbed out" flight that day, 9002 for the next, and so on.

But, the basic answer is that the ATC callsign of the flight changes.

Which does NOT mean, incidentally, that the flight number as far as the passengers are concerned has changed.  It's possible to be "Delta 9158" or "Delta 9001" or "Delta 158A" or whatever for ATC and still be "Flight 158" when talking on the PA to the passengers.  The fact that the ATC callsign changed is transparent to the rest of the operation, since reservations, ticket counter, baggage handling, and so forth isn't upset when 158 ICN-DTW happens to overlap (in time) 158 DTW-BOS.  Only ATC worries about that, so the fix is only visible to them (and the pilots &amp; dispatchers).