Skip to content

Commit 396a6a8

Browse files
committed
Enable InlineArray type sugar
Promote it from an experimental feature. rdar://155607927
1 parent de3e54a commit 396a6a8

File tree

11 files changed

+9
-53
lines changed

11 files changed

+9
-53
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ LANGUAGE_FEATURE(AddressOfProperty2, 0, "Builtin.unprotectedAddressOf properties
272272
LANGUAGE_FEATURE(NonescapableAccessorOnTrivial, 0, "Support UnsafeMutablePointer.mutableSpan")
273273
BASELINE_LANGUAGE_FEATURE(LayoutPrespecialization, 0, "Layout pre-specialization")
274274
BASELINE_LANGUAGE_FEATURE(IsolatedDeinit, 371, "isolated deinit")
275+
LANGUAGE_FEATURE(InlineArrayTypeSugar, 483, "Type sugar for InlineArray")
275276

276277
// Swift 6
277278
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
@@ -508,9 +509,6 @@ EXPERIMENTAL_FEATURE(CustomAvailability, true)
508509
/// Syntax sugar features for concurrency.
509510
EXPERIMENTAL_FEATURE(ConcurrencySyntaxSugar, true)
510511

511-
/// Enable syntax sugar type '[3 of Int]' for Inline Array
512-
EXPERIMENTAL_FEATURE(InlineArrayTypeSugar, false)
513-
514512
/// Allow declaration of compile-time values
515513
EXPERIMENTAL_FEATURE(CompileTimeValues, true)
516514

lib/ASTGen/Sources/ASTGen/SourceFile.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ extension Parser.ExperimentalFeatures {
7777
mapFeature(.CoroutineAccessors, to: .coroutineAccessors)
7878
mapFeature(.OldOwnershipOperatorSpellings, to: .oldOwnershipOperatorSpellings)
7979
mapFeature(.KeyPathWithMethodMembers, to: .keypathWithMethodMembers)
80-
mapFeature(.InlineArrayTypeSugar, to: .inlineArrayTypeSugar)
8180
mapFeature(.DefaultIsolationPerFile, to: .defaultIsolationPerFile)
8281
}
8382
}

lib/Parse/ParseType.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,8 +1318,6 @@ ParserResult<TypeRepr> Parser::parseTypeTupleBody() {
13181318
}
13191319

13201320
ParserResult<TypeRepr> Parser::parseTypeInlineArray(SourceLoc lSquare) {
1321-
ASSERT(Context.LangOpts.hasFeature(Feature::InlineArrayTypeSugar));
1322-
13231321
ParserStatus status;
13241322

13251323
// 'isStartOfInlineArrayTypeBody' means we should at least have a type and
@@ -1824,9 +1822,6 @@ bool Parser::canParseType() {
18241822
}
18251823

18261824
bool Parser::canParseStartOfInlineArrayType() {
1827-
if (!Context.LangOpts.hasFeature(Feature::InlineArrayTypeSugar))
1828-
return false;
1829-
18301825
// We must have at least '[<type> of', which cannot be any other kind of
18311826
// expression or type. We specifically look for any type, not just integers
18321827
// for better recovery in e.g cases where the user writes '[Int of 2]'. We
@@ -1844,9 +1839,6 @@ bool Parser::canParseStartOfInlineArrayType() {
18441839
}
18451840

18461841
bool Parser::isStartOfInlineArrayTypeBody() {
1847-
if (!Context.LangOpts.hasFeature(Feature::InlineArrayTypeSugar))
1848-
return false;
1849-
18501842
BacktrackingScope backtrack(*this);
18511843
return canParseStartOfInlineArrayType();
18521844
}
@@ -1856,7 +1848,7 @@ bool Parser::canParseCollectionType() {
18561848
return false;
18571849

18581850
// Check to see if we have an InlineArray sugar type.
1859-
if (Context.LangOpts.hasFeature(Feature::InlineArrayTypeSugar)) {
1851+
{
18601852
CancellableBacktrackingScope backtrack(*this);
18611853
if (canParseStartOfInlineArrayType()) {
18621854
backtrack.cancelBacktrack();

test/ASTGen/types.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@
22

33
// RUN: %target-swift-frontend-dump-parse -enable-experimental-feature ParserASTGen \
44
// RUN: -enable-experimental-feature NamedOpaqueTypes \
5-
// RUN: -enable-experimental-feature InlineArrayTypeSugar \
65
// RUN: | %sanitize-address > %t/astgen.ast
76
// RUN: %target-swift-frontend-dump-parse \
87
// RUN: -enable-experimental-feature NamedOpaqueTypes \
9-
// RUN: -enable-experimental-feature InlineArrayTypeSugar \
108
// RUN: | %sanitize-address > %t/cpp-parser.ast
119

1210
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
1311

1412
// RUN: %target-typecheck-verify-swift -enable-experimental-feature ParserASTGen \
15-
// RUN: -enable-experimental-feature NamedOpaqueTypes \
16-
// RUN: -enable-experimental-feature InlineArrayTypeSugar
13+
// RUN: -enable-experimental-feature NamedOpaqueTypes
1714

1815
// REQUIRES: swift_feature_ParserASTGen
1916
// REQUIRES: swift_feature_NamedOpaqueTypes
20-
// REQUIRES: swift_feature_InlineArrayTypeSugar
2117

2218
// rdar://116686158
2319
// UNSUPPORTED: asan

test/Availability/inline_array_availability.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// RUN: %target-typecheck-verify-swift -enable-experimental-feature InlineArrayTypeSugar -target %target-cpu-apple-macosx15.0
1+
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx15.0
22

3-
// REQUIRES: swift_feature_InlineArrayTypeSugar
43
// REQUIRES: OS=macosx
54

65
func foo(x: InlineArray<3, Int>) {}

test/DebugInfo/sugar_inline_array.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// RUN: %target-swift-frontend %s -emit-ir -enable-experimental-feature InlineArrayTypeSugar -disable-availability-checking -g -o - | %FileCheck %s
2-
3-
// REQUIRES: swift_feature_InlineArrayTypeSugar
1+
// RUN: %target-swift-frontend %s -emit-ir -disable-availability-checking -g -o - | %FileCheck %s
42

53
let a: ([3 of Int], InlineArray<3, Int>) = ([1, 2, 3], [1, 2, 3])
64
let b: ([3 of [1 of String]], InlineArray<3, InlineArray<1, String>>) = ([[""], [""], [""]], [[""], [""], [""]])

test/IDE/complete_inline_array.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// RUN: %batch-code-completion -enable-experimental-feature InlineArrayTypeSugar
2-
3-
// REQUIRES: swift_feature_InlineArrayTypeSugar
1+
// RUN: %batch-code-completion
42

53
struct FooBar {}
64

test/Sema/inlinearray.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-feature InlineArrayTypeSugar
2-
3-
// REQUIRES: swift_feature_InlineArrayTypeSugar
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking
42

53
let a: InlineArray = [1, 2, 3] // Ok, InlineArray<3, Int>
64
let b: InlineArray<_, Int> = [1, 2, 3] // Ok, InlineArray<3, Int>

test/Serialization/value_generics.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %s -emit-module -enable-experimental-feature RawLayout -enable-experimental-feature InlineArrayTypeSugar -disable-availability-checking -parse-as-library -o %t
2+
// RUN: %target-swift-frontend %s -emit-module -enable-experimental-feature RawLayout -disable-availability-checking -parse-as-library -o %t
33
// RUN: %target-sil-opt -enable-sil-verify-all %t/value_generics.swiftmodule -o - | %FileCheck %s
44

55
// REQUIRES: swift_feature_RawLayout
6-
// REQUIRES: swift_feature_InlineArrayTypeSugar
76

87
// CHECK: @_rawLayout(likeArrayOf: Element, count: Count) struct Vector<Element, let Count : Int> : ~Copyable where Element : ~Copyable {
98
@_rawLayout(likeArrayOf: Element, count: Count)

test/type/inline_array.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-experimental-feature InlineArrayTypeSugar -disable-availability-checking
2-
3-
// REQUIRES: swift_feature_InlineArrayTypeSugar
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking
42

53
let _: [3 of Int]
64
let _ = [3 of Int](repeating: 0)

0 commit comments

Comments
 (0)