Skip to content

Commit b392f4f

Browse files
committed
[CS] Correctly handle InlineArray in shrink
Previously we would try the contextual type `(<int>, <element>)`, which is wrong. Adjust the logic to only consider the element type. While here, also allow desugaring of the contextual type to find the element type.
1 parent 7d15ce0 commit b392f4f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,10 +1177,18 @@ void ConstraintSystem::shrink(Expr *expr) {
11771177
}
11781178

11791179
// Map or Set or any other associated collection type.
1180-
if (auto boundGeneric = dyn_cast<BoundGenericType>(base)) {
1180+
if (auto boundGeneric = base->getAs<BoundGenericType>()) {
11811181
if (boundGeneric->hasUnresolvedType())
11821182
return boundGeneric;
11831183

1184+
// The element type given by InlineArray is the second type.
1185+
if (boundGeneric->getDecl() == ctx.getInlineArrayDecl()) {
1186+
auto args = boundGeneric->getGenericArgs();
1187+
if (args.size() != 2)
1188+
return Type();
1189+
return args[1];
1190+
}
1191+
11841192
llvm::SmallVector<TupleTypeElt, 2> params;
11851193
for (auto &type : boundGeneric->getGenericArgs()) {
11861194
// One of the generic arguments in invalid or unresolved.

0 commit comments

Comments
 (0)