$ the-wire · showcase
Swift hardens noncopyable closure captures and casting
By RepoJournal · Filed · About Mobile platforms · Composed from the cited sources · methodology
Swift's compiler team spent the day closing crash paths in noncopyable and borrowing-capture handling, a cluster of fixes that turns IRGen and SILGen failures into move-checker diagnostics proper.
[Noncopyable Casting] Diagnose a consuming cast from a non-consumable source apple/swift
Patterns like `if let v = h.f as? T`, `guard let`, `while let` and `if case let v as T = h.f` over a non-Copyable class property, global, static, or escaping-closure capture used to crash IRGen; they are now rejected by the move checker as consuming casts from storage that does not permit consumption.
SIL: Don't box a borrowed closure parameter captured by an escaping closure apple/swift
SILGen boxed unannotated closure parameters that the closure's type marks as borrowed, so an escaping closure capturing one crashed the compiler rather than being diagnosed like an explicit `borrowing` parameter. Capture lowering now uses the parameter's lowered ownership instead of its written ownership.
[~Copyable Casting] Allow `as?`/`as!` with a ~Copyable type on either side apple/swift
`as?` and `as!` were previously limited to a non-copyable existential source and a concrete target; the constraints are relaxed so a much wider set of sources and destinations compiles, extending to casts the match-only consumption behavior that `if let`, `if case` and consuming `switch` already got.
Sema: Fix a couple issues with captures of noncopyable closures apple/swift
Capture computation no longer assumes a property has a getter, and captured parameters are not marked consumed unless they can actually be consumed, removing a class of compiler crashes on noncopyable closures.
[Dependency Scanning] Give the scanner a second chance when the incremental scan cache is stale apple/swift
Incremental dependency scanning reused prior results for modules whose inputs looked unchanged, but a cache check could miss edits that preserve an older modification time, and a mismatch with a fresh Clang context hash failed the scan with an "unexpected variant" error. Entries loaded from the prior scan are now marked, giving the scanner a second chance when the only problem is a stale cache.