mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Sema: Let .foo patterns fall back to being ExprPatterns if they don't match an enum case.
This lets you match `case .foo` when `foo` resolves to any static member, instead of only a `case`, albeit without the exhaustiveness checking and subpattern capabilities of proper cases. While we're here, adjust the type system we set up for unresolved patterns embedded in expressions so that we give better signal in the error messages too.
This commit is contained in:
@@ -2670,8 +2670,13 @@ namespace {
|
||||
|
||||
Type visitUnresolvedPatternExpr(UnresolvedPatternExpr *expr) {
|
||||
// If there are UnresolvedPatterns floating around after name binding,
|
||||
// they are pattern productions in invalid positions.
|
||||
return ErrorType::get(CS.getASTContext());
|
||||
// they are pattern productions in invalid positions. However, we will
|
||||
// diagnose that condition elsewhere; to avoid unnecessary noise errors,
|
||||
// just plop an open type variable here.
|
||||
|
||||
auto locator = CS.getConstraintLocator(expr);
|
||||
auto typeVar = CS.createTypeVariable(locator, TVO_CanBindToLValue);
|
||||
return typeVar;
|
||||
}
|
||||
|
||||
/// Get the type T?
|
||||
|
||||
Reference in New Issue
Block a user