mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Previously we would wait until CSApply, which would trigger their type-checking in `coercePatternToType`. This caused a number of bugs, and hampered solver-based completion, which does not run CSApply. Instead, form a conjunction of all the ExprPatterns present, which preserves some of the previous isolation behavior (though does not provide complete isolation). We can then modify `coercePatternToType` to accept a closure, which allows the solver to take over rewriting the ExprPatterns it has already solved. This then sets the stage for the complete removal of `coercePatternToType`, and doing all pattern type-checking in the solver.
21 lines
372 B
Swift
21 lines
372 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
// rdar://105781521
|
|
enum MyEnum {
|
|
case first(String)
|
|
}
|
|
|
|
func takeClosure(_ x: () -> Void) {}
|
|
|
|
func test(value: MyEnum) {
|
|
takeClosure {
|
|
switch value {
|
|
case .first(true):
|
|
// expected-error@-1 {{expression pattern of type 'Bool' cannot match values of type 'String'}}
|
|
break
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
}
|