mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #82988 from hamishknight/enable-inlinearray-sugar-6.2
[6.2] Enable InlineArray type sugar
This commit is contained in:
@@ -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)
|
||||
@@ -512,9 +513,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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -1844,9 +1839,6 @@ bool Parser::canParseStartOfInlineArrayType() {
|
||||
}
|
||||
|
||||
bool Parser::isStartOfInlineArrayTypeBody() {
|
||||
if (!Context.LangOpts.hasFeature(Feature::InlineArrayTypeSugar))
|
||||
return false;
|
||||
|
||||
BacktrackingScope backtrack(*this);
|
||||
return canParseStartOfInlineArrayType();
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>) {}
|
||||
|
||||
@@ -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>>) = ([[""], [""], [""]], [[""], [""], [""]])
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// RUN: %batch-code-completion -enable-experimental-feature InlineArrayTypeSugar
|
||||
|
||||
// REQUIRES: swift_feature_InlineArrayTypeSugar
|
||||
// RUN: %batch-code-completion
|
||||
|
||||
struct FooBar {}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
// Make sure InlineArray type sugar is disabled by default.
|
||||
// FIXME: The recovery here really isn't great.
|
||||
do {
|
||||
let _: [3 of Int] // expected-note {{to match this opening '['}}
|
||||
// expected-error@-1 4{{expected}}
|
||||
// expected-error@-2 4{{consecutive statements on a line must be separated by ';'}}
|
||||
// expected-warning@-3 2{{is unused}}
|
||||
// expected-error@-4 {{cannot find 'of' in scope}}
|
||||
// expected-note@-5 {{add arguments after the type to construct a value of the type}}
|
||||
// expected-note@-6 {{use '.self' to reference the type object}}
|
||||
}
|
||||
do {
|
||||
let _ = [3 of Int]()
|
||||
// expected-error@-1 {{cannot call value of non-function type '[Int]'}}
|
||||
// expected-error@-2 {{expected ',' separator}}
|
||||
// expected-error@-3 {{cannot find 'of' in scope}}
|
||||
}
|
||||
Reference in New Issue
Block a user