Skip to content

Commit 80c967e

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents df94a20 + eff13b7 commit 80c967e

File tree

13 files changed

+56
-65
lines changed

13 files changed

+56
-65
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();

lib/Sema/CSSimplify.cpp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10431,22 +10431,33 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
1043110431
}
1043210432

1043310433
const auto isUnsupportedExistentialMemberAccess = [&] {
10434+
if (!instanceTy->isExistentialType())
10435+
return false;
10436+
10437+
// If the base type is composed with marker protocol(s) i.e.
10438+
// `<<Type>> & Sendable`, let's skip this check because such
10439+
// compositions are always opened and simplified down to a
10440+
// superclass bound post-Sema.
10441+
if (auto *existential = instanceTy->getAs<ExistentialType>()) {
10442+
auto *compositionTy =
10443+
existential->getConstraintType()->getAs<ProtocolCompositionType>();
10444+
if (compositionTy &&
10445+
!compositionTy->withoutMarkerProtocols()->isExistentialType())
10446+
return false;
10447+
}
10448+
1043410449
// We may not be able to derive a well defined type for an existential
1043510450
// member access if the member's signature references 'Self'.
10436-
if (instanceTy->isExistentialType()) {
10437-
switch (isMemberAvailableOnExistential(instanceTy, decl)) {
10438-
case ExistentialMemberAccessLimitation::Unsupported:
10439-
// TODO: Write-only accesses are not supported yet.
10440-
case ExistentialMemberAccessLimitation::WriteOnly:
10441-
return true;
10451+
switch (isMemberAvailableOnExistential(instanceTy, decl)) {
10452+
case ExistentialMemberAccessLimitation::Unsupported:
10453+
// TODO: Write-only accesses are not supported yet.
10454+
case ExistentialMemberAccessLimitation::WriteOnly:
10455+
return true;
1044210456

10443-
case ExistentialMemberAccessLimitation::ReadOnly:
10444-
case ExistentialMemberAccessLimitation::None:
10445-
break;
10446-
}
10457+
case ExistentialMemberAccessLimitation::ReadOnly:
10458+
case ExistentialMemberAccessLimitation::None:
10459+
return false;
1044710460
}
10448-
10449-
return false;
1045010461
};
1045110462

1045210463
// See if we have an instance method, instance member or static method,

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/Interpreter/protocol_composition_with_markers.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,27 @@ do {
5858
generic(Int.self)
5959
// CHECK: D<Int>
6060
}
61+
62+
protocol Q {
63+
func update(_: [Self])
64+
}
65+
66+
extension Q {
67+
func update(_ arr: [Self]) { print(Self.self) }
68+
}
69+
70+
do {
71+
class Parent : Q {}
72+
class Subclass: Parent {}
73+
74+
func test(_ v: Parent & Sendable) {
75+
v.update([])
76+
}
77+
78+
test(Subclass())
79+
// CHECK: Subclass
80+
81+
let sendableV: any Subclass & Sendable = Subclass()
82+
test(sendableV)
83+
// CHECK: Subclass
84+
}

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>

0 commit comments

Comments
 (0)