Skip to content

Commit 4c0b580

Browse files
committed
Make _InlineArray subject to the same optimizations as InlineArray
1 parent b69d5fe commit 4c0b580

File tree

8 files changed

+9
-7
lines changed

8 files changed

+9
-7
lines changed

include/swift/AST/KnownStdlibTypes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ KNOWN_STDLIB_TYPE_DECL(DecodingError, NominalTypeDecl, 0)
101101
KNOWN_STDLIB_TYPE_DECL(Result, NominalTypeDecl, 2)
102102

103103
KNOWN_STDLIB_TYPE_DECL(InlineArray, NominalTypeDecl, 2)
104+
KNOWN_STDLIB_TYPE_DECL(_InlineArray, NominalTypeDecl, 2)
104105

105106
KNOWN_STDLIB_TYPE_DECL(MutableSpan, NominalTypeDecl, 1)
106107

lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ Type TypeBase::getArrayElementType() {
853853
}
854854

855855
Type TypeBase::getInlineArrayElementType() {
856-
if (!isInlineArray())
856+
if (!isInlineArray() && !is_InlineArray())
857857
return Type();
858858

859859
if (!is<BoundGenericStructType>())

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
13581358
// these can be reconstructed by substituting the "template parameters" in
13591359
// the unspecialized type. We make an exception for inline arrays, because
13601360
// DWARF has special support for arrays.
1361-
if (Type->isInlineArray() && !Type->hasTypeParameter() &&
1361+
if ((Type->isInlineArray() || Type->is_InlineArray()) &&
1362+
!Type->hasTypeParameter() &&
13621363
!Type->hasPrimaryArchetype())
13631364
// Create the substituted type.
13641365
return createStructType(Type, Decl, Scope, File, Line, SizeInBits,

lib/SILGen/SILGenExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5178,7 +5178,7 @@ static RValue emitInlineArrayLiteral(SILGenFunction &SGF, CollectionExpr *E,
51785178

51795179
RValue RValueEmitter::visitCollectionExpr(CollectionExpr *E, SGFContext C) {
51805180
// Handle 'InlineArray' literals separately.
5181-
if (E->getType()->isInlineArray()) {
5181+
if (E->getType()->isInlineArray() || E->getType()->is_InlineArray()) {
51825182
return emitInlineArrayLiteral(SGF, E, C);
51835183
}
51845184

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3976,7 +3976,7 @@ namespace {
39763976
Type arrayTy = cs.getType(expr);
39773977
Type elementType;
39783978

3979-
if (arrayTy->isInlineArray()) {
3979+
if (arrayTy->isInlineArray() || arrayTy->is_InlineArray()) {
39803980
// <let count: Int, Element>
39813981
elementType = arrayTy->castTo<BoundGenericStructType>()->getGenericArgs()[1];
39823982
} else {

lib/Sema/CSGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,7 @@ namespace {
22082208
if (contextualType->isArray())
22092209
eltType = contextualType->getArrayElementType();
22102210

2211-
if (contextualType->isInlineArray())
2211+
if (contextualType->isInlineArray() || contextualType->is_InlineArray())
22122212
eltType = contextualType->getInlineArrayElementType();
22132213

22142214
CS.addConstraint(ConstraintKind::LiteralConformsTo, contextualType,

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8986,7 +8986,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
89868986
// parameter, then check if the counts are equal and solve.
89878987
if (kind == ConstraintKind::LiteralConformsTo &&
89888988
protocol == arrayLiteralProto &&
8989-
type->isInlineArray() &&
8989+
(type->isInlineArray() || type->is_InlineArray()) &&
89908990
arrayLiteral) {
89918991
auto iaTy = type->castTo<BoundGenericStructType>();
89928992

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ struct TypeSimplifier {
17921792
// Special case: When building slab literals, we go through the same
17931793
// array literal machinery, so there will be a conversion constraint
17941794
// for the element to ExpressibleByArrayLiteral.ArrayLiteralType.
1795-
if (lookupBaseType->isInlineArray()) {
1795+
if (lookupBaseType->isInlineArray() || lookupBaseType->is_InlineArray()) {
17961796
auto &ctx = CS.getASTContext();
17971797
auto arrayProto =
17981798
ctx.getProtocol(KnownProtocolKind::ExpressibleByArrayLiteral);

0 commit comments

Comments
 (0)