File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -2252,13 +2252,19 @@ namespace {
2252
2252
2253
2253
case PatternKind::Typed: {
2254
2254
// FIXME: Need a better locator for a pattern as a base.
2255
+ // Compute the type ascribed to the pattern.
2255
2256
auto contextualPattern =
2256
2257
ContextualPattern::forRawPattern (pattern, CurDC);
2257
2258
Type type = TypeChecker::typeCheckPattern (contextualPattern);
2258
2259
Type openedType = CS.openUnboundGenericType (type, locator);
2259
2260
2260
- // For a typed pattern, simply return the opened type of the pattern.
2261
- // FIXME: Error recovery if the type is an error type?
2261
+ // Determine the subpattern type. It will be convertible to the
2262
+ // ascribed type.
2263
+ Type subPatternType =
2264
+ getTypeForPattern (
2265
+ cast<TypedPattern>(pattern)->getSubPattern (), locator);
2266
+ CS.addConstraint (
2267
+ ConstraintKind::Conversion, subPatternType, openedType, locator);
2262
2268
return setType (openedType);
2263
2269
}
2264
2270
You can’t perform that action at this time.
0 commit comments