Skip to content

Commit 3e0de86

Browse files
Removed the feature and made changes unconditional
1 parent 5a69c8e commit 3e0de86

File tree

15 files changed

+72
-200
lines changed

15 files changed

+72
-200
lines changed

include/swift/Basic/Features.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,6 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ExtensibleAttribute, false)
511511
/// Allow use of `Module::name` syntax
512512
EXPERIMENTAL_FEATURE(ModuleSelector, false)
513513

514-
/// Allow `weak let` and make weak captures immutable
515-
EXPERIMENTAL_FEATURE(WeakLet, true)
516-
517514
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
518515
#undef EXPERIMENTAL_FEATURE
519516
#undef UPCOMING_FEATURE

lib/AST/Expr.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,10 +1366,8 @@ CaptureListEntry CaptureListEntry::createParsed(
13661366
SourceRange ownershipRange, Identifier name, SourceLoc nameLoc,
13671367
SourceLoc equalLoc, Expr *initializer, DeclContext *DC) {
13681368

1369-
bool forceVar = ownershipKind == ReferenceOwnership::Weak && !Ctx.LangOpts.hasFeature(Feature::WeakLet);
1370-
auto introducer = forceVar ? VarDecl::Introducer::Var : VarDecl::Introducer::Let;
13711369
auto *VD =
1372-
new (Ctx) VarDecl(/*isStatic==*/false, introducer, nameLoc, name, DC);
1370+
new (Ctx) VarDecl(/*isStatic==*/false, VarDecl::Introducer::Let, nameLoc, name, DC);
13731371

13741372
if (ownershipKind != ReferenceOwnership::Strong)
13751373
VD->getAttrs().add(

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -624,15 +624,6 @@ static bool usesFeatureExtensibleAttribute(Decl *decl) {
624624
return decl->getAttrs().hasAttribute<ExtensibleAttr>();
625625
}
626626

627-
static bool usesFeatureWeakLet(Decl *decl) {
628-
if (auto *VD = dyn_cast<VarDecl>(decl)) {
629-
if (auto *refAttr = VD->getAttrs().getAttribute<ReferenceOwnershipAttr>()) {
630-
return VD->isLet() && refAttr->get() == ReferenceOwnership::Weak;
631-
}
632-
}
633-
return false;
634-
}
635-
636627
// ----------------------------------------------------------------------------
637628
// MARK: - FeatureSet
638629
// ----------------------------------------------------------------------------

lib/SIL/IR/TypeLowering.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,6 @@ CaptureKind TypeConverter::getDeclCaptureKind(CapturedValue capture,
170170
return CaptureKind::StorageAddress;
171171
}
172172

173-
// Reference storage types can appear in a capture list, which means
174-
// we might allocate boxes to store the captures. However, those boxes
175-
// have the same lifetime as the closure itself, so we must capture
176-
// the box itself and not the payload, even if the closure is noescape,
177-
// otherwise they will be destroyed when the closure is formed.
178-
if (var->getInterfaceType()->is<ReferenceStorageType>() && !Context.LangOpts.hasFeature(Feature::WeakLet)) {
179-
return CaptureKind::Box;
180-
}
181-
182173
// For 'let' constants
183174
if (!var->supportsMutation()) {
184175
assert(getTypeLowering(

lib/Sema/MiscDiagnostics.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4003,11 +4003,6 @@ VarDeclUsageChecker::~VarDeclUsageChecker() {
40034003
access &= ~RK_Written;
40044004
}
40054005

4006-
// If this variable has WeakStorageType, then it can be mutated in ways we
4007-
// don't know.
4008-
if (var->getInterfaceType()->is<WeakStorageType>() && !DC->getASTContext().LangOpts.hasFeature(Feature::WeakLet))
4009-
access |= RK_Written;
4010-
40114006
// Diagnose variables that were never used (other than their
40124007
// initialization).
40134008
//

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5285,11 +5285,6 @@ Type TypeChecker::checkReferenceOwnershipAttr(VarDecl *var, Type type,
52855285
case ReferenceOwnershipOptionality::Allowed:
52865286
break;
52875287
case ReferenceOwnershipOptionality::Required:
5288-
if (var->isLet() && !ctx.LangOpts.hasFeature(Feature::WeakLet)) {
5289-
var->diagnose(diag::invalid_ownership_is_let, ownershipKind);
5290-
attr->setInvalid();
5291-
}
5292-
52935288
if (!isOptional) {
52945289
attr->setInvalid();
52955290

test/Concurrency/weak_ref_sendability.swift

Lines changed: 41 additions & 89 deletions
Large diffs are not rendered by default.

test/DebugInfo/WeakCapture.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
2-
// RUN: %target-swift-frontend %s -enable-experimental-feature WeakLet -emit-ir -g -o - | %FileCheck %s
3-
4-
// REQUIRES: swift_feature_WeakLet
5-
62
class A {
73
init(handler: (() -> ())) { }
84
}

test/DebugInfo/weak-self-capture.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
2-
// RUN: %target-swift-frontend %s -enable-experimental-feature WeakLet -emit-ir -g -o - | %FileCheck %s
3-
4-
// REQUIRES: swift_feature_WeakLet
5-
62
public class ClosureMaker {
73
var a : Int
84

test/Interpreter/weak.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// RUN: %target-run-simple-swift | %FileCheck %s
2-
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-feature -Xfrontend WeakLet) | %FileCheck %s --check-prefixes=CHECK,CHECK-WEAK-LET
3-
42
// REQUIRES: executable_test
5-
// REQUIRES: swift_feature_WeakLet
63

74
protocol Protocol : class {
85
func noop()
@@ -79,19 +76,17 @@ func testWeakInLet() {
7976

8077
testWeakInLet()
8178

82-
#if hasFeature(WeakLet)
8379
func testWeakLet() {
84-
print("testWeakLet") // CHECK-WEAK-LET-LABEL: testWeakLet
80+
print("testWeakLet") // CHECK-LABEL: testWeakLet
8581

86-
var obj: SwiftClassBase? = SwiftClass() // CHECK-WEAK-LET: SwiftClass Created
82+
var obj: SwiftClassBase? = SwiftClass() // CHECK: SwiftClass Created
8783
weak let weakRef = obj
88-
printState(weakRef) // CHECK-WEAK-LET-NEXT: is present
89-
obj = nil // CHECK-WEAK-LET-NEXT: SwiftClass Destroyed
90-
printState(weakRef) // CHECK-WEAK-LET-NEXT: is nil
84+
printState(weakRef) // CHECK-NEXT: is present
85+
obj = nil // CHECK-NEXT: SwiftClass Destroyed
86+
printState(weakRef) // CHECK-NEXT: is nil
9187
}
9288

9389
testWeakLet()
94-
#endif
9590

9691

9792
//======================== Test Classbound Protocols ========================

0 commit comments

Comments
 (0)