mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
d44949b5b0
The body of a `@backDeployed` function is emitted twice during SILGen: once for the original copy and once for the fallback copy that is emitted into the client and run on OSes where the original is unavailable. As a result, any nested local function declared in the body is visited twice. Nested closures were already handled correctly because `emitClosure()` skips re-emission of a closure that has already been defined. A nested named function, however, took a different path: since it has user-written code it is not delayable, so `emitOrDelayFunction()` emitted its definition unconditionally on each visit. The second emission then tripped the 'multiple definitions of symbol' diagnostic. Fix this by teaching the non-delayable path in `emitOrDelayFunction()` to skip a function that has already been defined, mirroring `emitClosure()`. The nested function is emitted a single time with shared linkage and referenced from both copies of the enclosing function, just as a nested closure is. Resolves rdar://105137047