Skip to content

[6.2] Enable InlineArray type sugar #82988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release/6.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(ABIAttributeSE0479, 479, "@abi attribute on functi
LANGUAGE_FEATURE(BuiltinSelect, 0, "Builtin.select")
LANGUAGE_FEATURE(AlwaysInheritActorContext, 472, "@_inheritActorContext(always)")
LANGUAGE_FEATURE(NonescapableAccessorOnTrivial, 0, "Support UnsafeMutablePointer.mutableSpan")
LANGUAGE_FEATURE(InlineArrayTypeSugar, 483, "Type sugar for InlineArray")

// Swift 6
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
Expand Down Expand Up @@ -508,9 +509,6 @@ EXPERIMENTAL_FEATURE(ExtensibleEnums, true)
/// Syntax sugar features for concurrency.
EXPERIMENTAL_FEATURE(ConcurrencySyntaxSugar, true)

/// Enable syntax sugar type '[3 of Int]' for Inline Array
EXPERIMENTAL_FEATURE(InlineArrayTypeSugar, false)

/// Allow declaration of compile-time values
EXPERIMENTAL_FEATURE(CompileTimeValues, true)

Expand Down
1 change: 0 additions & 1 deletion lib/ASTGen/Sources/ASTGen/SourceFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ extension Parser.ExperimentalFeatures {
mapFeature(.CoroutineAccessors, to: .coroutineAccessors)
mapFeature(.OldOwnershipOperatorSpellings, to: .oldOwnershipOperatorSpellings)
mapFeature(.KeyPathWithMethodMembers, to: .keypathWithMethodMembers)
mapFeature(.InlineArrayTypeSugar, to: .inlineArrayTypeSugar)
mapFeature(.DefaultIsolationPerFile, to: .defaultIsolationPerFile)
}
}
Expand Down
10 changes: 1 addition & 9 deletions lib/Parse/ParseType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,8 +1318,6 @@ ParserResult<TypeRepr> Parser::parseTypeTupleBody() {
}

ParserResult<TypeRepr> Parser::parseTypeInlineArray(SourceLoc lSquare) {
ASSERT(Context.LangOpts.hasFeature(Feature::InlineArrayTypeSugar));

ParserStatus status;

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

bool Parser::canParseStartOfInlineArrayType() {
if (!Context.LangOpts.hasFeature(Feature::InlineArrayTypeSugar))
return false;

// We must have at least '[<type> of', which cannot be any other kind of
// expression or type. We specifically look for any type, not just integers
// for better recovery in e.g cases where the user writes '[Int of 2]'. We
Expand All @@ -1844,9 +1839,6 @@ bool Parser::canParseStartOfInlineArrayType() {
}

bool Parser::isStartOfInlineArrayTypeBody() {
if (!Context.LangOpts.hasFeature(Feature::InlineArrayTypeSugar))
return false;

BacktrackingScope backtrack(*this);
return canParseStartOfInlineArrayType();
}
Expand All @@ -1856,7 +1848,7 @@ bool Parser::canParseCollectionType() {
return false;

// Check to see if we have an InlineArray sugar type.
if (Context.LangOpts.hasFeature(Feature::InlineArrayTypeSugar)) {
{
CancellableBacktrackingScope backtrack(*this);
if (canParseStartOfInlineArrayType()) {
backtrack.cancelBacktrack();
Expand Down
6 changes: 1 addition & 5 deletions test/ASTGen/types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@

// RUN: %target-swift-frontend-dump-parse -enable-experimental-feature ParserASTGen \
// RUN: -enable-experimental-feature NamedOpaqueTypes \
// RUN: -enable-experimental-feature InlineArrayTypeSugar \
// RUN: | %sanitize-address > %t/astgen.ast
// RUN: %target-swift-frontend-dump-parse \
// RUN: -enable-experimental-feature NamedOpaqueTypes \
// RUN: -enable-experimental-feature InlineArrayTypeSugar \
// RUN: | %sanitize-address > %t/cpp-parser.ast

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

// RUN: %target-typecheck-verify-swift -enable-experimental-feature ParserASTGen \
// RUN: -enable-experimental-feature NamedOpaqueTypes \
// RUN: -enable-experimental-feature InlineArrayTypeSugar
// RUN: -enable-experimental-feature NamedOpaqueTypes

// REQUIRES: swift_feature_ParserASTGen
// REQUIRES: swift_feature_NamedOpaqueTypes
// REQUIRES: swift_feature_InlineArrayTypeSugar

// rdar://116686158
// UNSUPPORTED: asan
Expand Down
3 changes: 1 addition & 2 deletions test/Availability/inline_array_availability.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// RUN: %target-typecheck-verify-swift -enable-experimental-feature InlineArrayTypeSugar -target %target-cpu-apple-macosx15.0
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx15.0

// REQUIRES: swift_feature_InlineArrayTypeSugar
// REQUIRES: OS=macosx

func foo(x: InlineArray<3, Int>) {}
Expand Down
4 changes: 1 addition & 3 deletions test/DebugInfo/sugar_inline_array.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// RUN: %target-swift-frontend %s -emit-ir -enable-experimental-feature InlineArrayTypeSugar -disable-availability-checking -g -o - | %FileCheck %s

// REQUIRES: swift_feature_InlineArrayTypeSugar
// RUN: %target-swift-frontend %s -emit-ir -disable-availability-checking -g -o - | %FileCheck %s

let a: ([3 of Int], InlineArray<3, Int>) = ([1, 2, 3], [1, 2, 3])
let b: ([3 of [1 of String]], InlineArray<3, InlineArray<1, String>>) = ([[""], [""], [""]], [[""], [""], [""]])
Expand Down
4 changes: 1 addition & 3 deletions test/IDE/complete_inline_array.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// RUN: %batch-code-completion -enable-experimental-feature InlineArrayTypeSugar

// REQUIRES: swift_feature_InlineArrayTypeSugar
// RUN: %batch-code-completion

struct FooBar {}

Expand Down
4 changes: 1 addition & 3 deletions test/Sema/inlinearray.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-feature InlineArrayTypeSugar

// REQUIRES: swift_feature_InlineArrayTypeSugar
// RUN: %target-typecheck-verify-swift -disable-availability-checking

let a: InlineArray = [1, 2, 3] // Ok, InlineArray<3, Int>
let b: InlineArray<_, Int> = [1, 2, 3] // Ok, InlineArray<3, Int>
Expand Down
3 changes: 1 addition & 2 deletions test/Serialization/value_generics.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -emit-module -enable-experimental-feature RawLayout -enable-experimental-feature InlineArrayTypeSugar -disable-availability-checking -parse-as-library -o %t
// RUN: %target-swift-frontend %s -emit-module -enable-experimental-feature RawLayout -disable-availability-checking -parse-as-library -o %t
// RUN: %target-sil-opt -enable-sil-verify-all %t/value_generics.swiftmodule -o - | %FileCheck %s

// REQUIRES: swift_feature_RawLayout
// REQUIRES: swift_feature_InlineArrayTypeSugar

// CHECK: @_rawLayout(likeArrayOf: Element, count: Count) struct Vector<Element, let Count : Int> : ~Copyable where Element : ~Copyable {
@_rawLayout(likeArrayOf: Element, count: Count)
Expand Down
4 changes: 1 addition & 3 deletions test/type/inline_array.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// RUN: %target-typecheck-verify-swift -enable-experimental-feature InlineArrayTypeSugar -disable-availability-checking

// REQUIRES: swift_feature_InlineArrayTypeSugar
// RUN: %target-typecheck-verify-swift -disable-availability-checking

let _: [3 of Int]
let _ = [3 of Int](repeating: 0)
Expand Down
19 changes: 0 additions & 19 deletions test/type/inline_array_disabled.swift

This file was deleted.