swift
8ea2d0dd - Sema: Fix conditional downcasts from Swift types to CF types

Commit
8 years ago
Sema: Fix conditional downcasts from Swift types to CF types Conditional and forced downcasts enter a constraint that almost always succeeds; only when applying the solution do we evaluate the feasability of the cast and determine if it always succeeds, always fails, or conditionally succeeds. This changes how the resulting AST is represented and can also emit diagnostics. If the conditional cast is at this stage determined to always succeed, we treat it as an unconditional cast, going through ExprRewriter::coerceToType() to build the AST for the coercion. However conditional cast constraints don't enter the same restrictions into the solution as unconditional casts do, so coerceToType() would fall over if casting a Swift type to a CF type by first bridging the Swift type to Objective-C. Get around this by checking for this case explicitly when lowering a CoerceExpr. It feels like there's a more fundamental issue here with how casts are modeled in the constraint solver, but I'm not going to try understanding that now. Fixes <rdar://problem/32227571>.
Author
Committer
Parents
Loading