mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Type checker] Introduce "contextual patterns".
Contextual pattern describes a particular pattern with enough contextual information to determine its type. Use this to simplify TypeChecker::typeCheckPattern()'s interface in a manner that will admit request'ification.
This commit is contained in:
@@ -2159,9 +2159,9 @@ namespace {
|
||||
|
||||
case PatternKind::Typed: {
|
||||
// FIXME: Need a better locator for a pattern as a base.
|
||||
TypeResolutionOptions options(TypeResolverContext::InExpression);
|
||||
options |= TypeResolutionFlags::AllowUnboundGenerics;
|
||||
Type type = TypeChecker::typeCheckPattern(pattern, CurDC, options);
|
||||
auto contextualPattern =
|
||||
ContextualPattern::forRawPattern(pattern, CurDC);
|
||||
Type type = TypeChecker::typeCheckPattern(contextualPattern);
|
||||
Type openedType = CS.openUnboundGenericType(type, locator);
|
||||
|
||||
// For a typed pattern, simply return the opened type of the pattern.
|
||||
|
||||
Reference in New Issue
Block a user