Skip to content

Commit d5970d9

Browse files
committed
Check if we're a bound struct
1 parent e68b398 commit d5970d9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/AST/Type.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,9 @@ Type TypeBase::getArrayElementType() {
833833
if (!isArray())
834834
return Type();
835835

836+
if (!is<BoundGenericStructType>())
837+
return Type();
838+
836839
// Array<T>
837840
auto boundStruct = castTo<BoundGenericStructType>();
838841
return boundStruct->getGenericArgs()[0];
@@ -842,6 +845,9 @@ Type TypeBase::getInlineArrayElementType() {
842845
if (!isInlineArray())
843846
return Type();
844847

848+
if (!is<BoundGenericStructType>())
849+
return Type();
850+
845851
// InlineArray<n, T>
846852
auto boundStruct = castTo<BoundGenericStructType>();
847853
return boundStruct->getGenericArgs()[1];

lib/Sema/CSGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2157,7 +2157,8 @@ namespace {
21572157

21582158
// If a contextual type exists for this expression, apply it directly.
21592159
if (contextualType &&
2160-
(contextualType->isArray() || contextualType->isInlineArray())) {
2160+
(contextualType->getArrayElementType() ||
2161+
contextualType->getInlineArrayElementType())) {
21612162
// Now that we know we're actually going to use the type, get the
21622163
// version for use in a constraint.
21632164
contextualType = CS.getContextualType(expr, /*forConstraint=*/true);

0 commit comments

Comments
 (0)