Skip to content

Commit c2db918

Browse files
committed
CS: Address an outdated OpenUnboundGenericType FIXME
1 parent 1420a38 commit c2db918

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lib/Sema/CSGen.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3038,21 +3038,14 @@ namespace {
30383038
Type visitCoerceExpr(CoerceExpr *expr) {
30393039
// Validate the resulting type.
30403040
auto *const repr = expr->getCastTypeRepr();
3041-
const auto type = resolveTypeReferenceInExpression(
3042-
repr, TypeResolverContext::ExplicitCastExpr, [](auto unboundTy) {
3043-
// FIXME: We ought to pass an OpenUnboundGenericType object rather
3044-
// than calling CS.openUnboundGenericType after resolving, but
3045-
// sometimes the type expression is resolved eagerly in
3046-
// PreCheckExpression::simplifyTypeConstructionWithLiteralArg,
3047-
// letting unbound generics escape.
3048-
return unboundTy;
3049-
});
3050-
if (!type)
3041+
const auto toType = resolveTypeReferenceInExpression(
3042+
repr, TypeResolverContext::ExplicitCastExpr,
3043+
// Introduce type variables for unbound generics.
3044+
OpenUnboundGenericType(CS, CS.getConstraintLocator(expr)));
3045+
if (!toType)
30513046
return nullptr;
30523047

3053-
// Open the type we're casting to.
3054-
const auto toType =
3055-
CS.openUnboundGenericTypes(type, CS.getConstraintLocator(expr));
3048+
// Cache the type we're casting to.
30563049
if (repr) CS.setType(repr, toType);
30573050

30583051
auto fromType = CS.getType(expr->getSubExpr());

0 commit comments

Comments
 (0)