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 ========================

test/Interpreter/weak_objc.swift

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
// RUN: %target-build-swift %s -Xfrontend -disable-objc-attr-requires-foundation-module -enable-experimental-feature WeakLet -o %t-main
1+
// RUN: %target-build-swift %s -Xfrontend -disable-objc-attr-requires-foundation-module -o %t-main
22
// RUN: %target-codesign %t-main
33
// RUN: %target-run %t-main | %FileCheck %s
4-
5-
// RUN: %target-build-swift %s -Xfrontend -disable-objc-attr-requires-foundation-module -enable-experimental-feature WeakLet -o %t-main-weak-let
6-
// RUN: %target-codesign %t-main-weak-let
7-
// RUN: %target-run %t-main-weak-let | %FileCheck %s --check-prefixes=CHECK,CHECK-WEAK-LET
8-
94
// REQUIRES: executable_test
105
// REQUIRES: objc_interop
11-
// REQUIRES: swift_feature_WeakLet
126

137
import Foundation
148

@@ -54,30 +48,28 @@ func testObjCClass() {
5448

5549
testObjCClass()
5650

57-
#if hasFeature(WeakLet)
5851
func testObjCWeakLet() {
59-
print("testObjCWeakLet") // CHECK-WEAK-LET: testObjCWeakLet
52+
print("testObjCWeakLet") // CHECK: testObjCWeakLet
6053

61-
var c : ObjCClassBase = ObjCClass() // CHECK-WEAK-LET: ObjCClass Created
54+
var c : ObjCClassBase = ObjCClass() // CHECK: ObjCClass Created
6255
weak let w : ObjCClassBase? = c
63-
printState(w) // CHECK-WEAK-LET-NEXT: is present
64-
c = ObjCClassBase() // CHECK-WEAK-LET-NEXT: ObjCClass Destroyed
65-
printState(w) // CHECK-WEAK-LET-NEXT: is nil
56+
printState(w) // CHECK-NEXT: is present
57+
c = ObjCClassBase() // CHECK-NEXT: ObjCClass Destroyed
58+
printState(w) // CHECK-NEXT: is nil
6659
}
6760

6861
testObjCWeakLet()
6962

7063
func testObjCWeakLetCapture() {
71-
print("testObjCWeakLetCapture") // CHECK-WEAK-LET: testObjCWeakLetCapture
64+
print("testObjCWeakLetCapture") // CHECK: testObjCWeakLetCapture
7265

73-
var c : ObjCClassBase = ObjCClass() // CHECK-WEAK-LET: ObjCClass Created
66+
var c : ObjCClassBase = ObjCClass() // CHECK: ObjCClass Created
7467
let closure: () -> ObjCClassBase? = { [weak c] in c }
75-
printState(closure()) // CHECK-WEAK-LET-NEXT: is present
76-
printState(closure()) // CHECK-WEAK-LET-NEXT: is present
77-
c = ObjCClassBase() // CHECK-WEAK-LET-NEXT: ObjCClass Destroyed
78-
printState(closure()) // CHECK-WEAK-LET-NEXT: is nil
79-
printState(closure()) // CHECK-WEAK-LET-NEXT: is nil
68+
printState(closure()) // CHECK-NEXT: is present
69+
printState(closure()) // CHECK-NEXT: is present
70+
c = ObjCClassBase() // CHECK-NEXT: ObjCClass Destroyed
71+
printState(closure()) // CHECK-NEXT: is nil
72+
printState(closure()) // CHECK-NEXT: is nil
8073
}
8174

8275
testObjCWeakLetCapture()
83-
#endif

test/SILGen/weak.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -module-name weak -Xllvm -sil-full-demangle %s | %FileCheck %s
2-
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -module-name weak -Xllvm -sil-full-demangle %s -enable-experimental-feature WeakLet | %FileCheck %s
31

4-
// REQUIRES: swift_feature_WeakLet
2+
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types -module-name weak -Xllvm -sil-full-demangle %s | %FileCheck %s
53

64
class C {
75
func f() -> Int { return 42 }
@@ -69,7 +67,6 @@ func testClosureOverWeak() {
6967
takeClosure { bC!.f() }
7068
}
7169

72-
#if hasFeature(WeakLet)
7370
func testClosureOverWeakLet() {
7471
weak let bC = C()
7572
takeClosure { bC!.f() }
@@ -80,8 +77,6 @@ func testClosureOverWeakCapture() {
8077
takeClosure { [weak bC] in bC!.f() }
8178
}
8279

83-
#endif
84-
8580
class CC {
8681
weak var x: CC?
8782

test/expr/closure/closures_swift6.swift

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
// There seems to be a minor bug in the diagnostic of the self-capture.
2-
// Diagnostic algorithm does not @lvalue DeclRefExpr wrapped into LoadExpr,
3-
// and enabling WeakLet removes the LoadExpr.
4-
// As a result, diagnostic messages change slightly.
5-
6-
// RUN: %target-typecheck-verify-swift -swift-version 6 -verify-additional-prefix no-weak-let-
7-
// RUN: %target-typecheck-verify-swift -swift-version 6 -verify-additional-prefix has-weak-let- -enable-experimental-feature WeakLet
8-
9-
// REQUIRES: swift_feature_WeakLet
1+
// RUN: %target-typecheck-verify-swift -swift-version 6
102

113
func doStuff(_ fn : @escaping () -> Int) {}
124
func doVoidStuff(_ fn : @escaping () -> ()) {}
@@ -944,8 +936,7 @@ class TestExtensionOnOptionalSelf {
944936
extension TestExtensionOnOptionalSelf? {
945937
func foo() {
946938
_ = { [weak self] in
947-
// expected-no-weak-let-error@+2 {{implicit use of 'self' in closure; use 'self.' to make capture semantics explicit}}
948-
// expected-has-weak-let-error@+1 {{call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit}}
939+
// expected-error@+1 {{call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit}}
949940
foo()
950941
}
951942

@@ -956,10 +947,9 @@ extension TestExtensionOnOptionalSelf? {
956947
}
957948

958949
_ = { [weak self] in
959-
_ = { // expected-has-weak-let-note {{capture 'self' explicitly to enable implicit 'self' in this closure}}
960-
// expected-no-weak-let-error@+3 {{implicit use of 'self' in closure; use 'self.' to make capture semantics explicit}}
961-
// expected-has-weak-let-error@+2 {{call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit}}
962-
// expected-has-weak-let-note@+1 {{reference 'self.' explicitly}}
950+
_ = { // expected-note {{capture 'self' explicitly to enable implicit 'self' in this closure}}
951+
// expected-error@+2 {{call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit}}
952+
// expected-note@+1 {{reference 'self.' explicitly}}
963953
foo()
964954
self.foo()
965955
self?.bar()
@@ -980,8 +970,7 @@ extension TestExtensionOnOptionalSelf? {
980970
extension TestExtensionOnOptionalSelf {
981971
func foo() {
982972
_ = { [weak self] in
983-
// expected-no-weak-let-error@+2 {{implicit use of 'self' in closure; use 'self.' to make capture semantics explicit}}
984-
// expected-has-weak-let-error@+1 {{call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit}}
973+
// expected-error@+1 {{call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit}}
985974
foo()
986975
self.foo()
987976
self?.bar()
@@ -993,10 +982,9 @@ extension TestExtensionOnOptionalSelf {
993982
}
994983

995984
_ = { [weak self] in
996-
_ = { // expected-has-weak-let-note {{capture 'self' explicitly to enable implicit 'self' in this closure}}
997-
// expected-no-weak-let-error@+3 {{implicit use of 'self' in closure; use 'self.' to make capture semantics explicit}}
998-
// expected-has-weak-let-error@+2 {{call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit}}
999-
// expected-has-weak-let-note@+1 {{reference 'self.' explicitly}}
985+
_ = { // expected-note {{capture 'self' explicitly to enable implicit 'self' in this closure}}
986+
// expected-error@+2 {{call to method 'foo' in closure requires explicit use of 'self' to make capture semantics explicit}}
987+
// expected-note@+1 {{reference 'self.' explicitly}}
1000988
foo()
1001989
self.foo()
1002990
}

test/expr/closure/implicit_weak_capture.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -swift-version 6)
2-
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking -swift-version 6 -enable-experimental-feature WeakLet)
32

43
// REQUIRES: concurrency
54
// REQUIRES: executable_test
6-
// REQUIRES: swift_feature_WeakLet
75

86
// rdar://102155748
97
// UNSUPPORTED: back_deployment_runtime

test/stdlib/WeakMirror.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414
// RUN: if [ %target-runtime == "objc" ]; \
1515
// RUN: then \
1616
// RUN: %target-clang %S/Inputs/Mirror/Mirror.mm -c -o %t/Mirror.mm.o -g && \
17-
// RUN: %target-build-swift -Xfrontend -disable-access-control -Xfrontend -enable-experimental-feature -Xfrontend WeakLet %s -I %S/Inputs/Mirror/ -Xlinker %t/Mirror.mm.o -o %t/Mirror; \
17+
// RUN: %target-build-swift -Xfrontend -disable-access-control %s -I %S/Inputs/Mirror/ -Xlinker %t/Mirror.mm.o -o %t/Mirror; \
1818
// RUN: else \
19-
// RUN: %target-build-swift %s -Xfrontend -disable-access-control -Xfrontend -enable-experimental-feature -Xfrontend WeakLet -o %t/Mirror; \
19+
// RUN: %target-build-swift %s -Xfrontend -disable-access-control -o %t/Mirror; \
2020
// RUN: fi
2121
// RUN: %target-codesign %t/Mirror
2222
// RUN: %target-run %t/Mirror
2323

2424
// REQUIRES: executable_test
2525
// REQUIRES: shell
2626
// REQUIRES: reflection
27-
// REQUIRES: swift_feature_WeakLet
2827

2928
import StdlibUnittest
3029

@@ -124,7 +123,6 @@ mirrors.test("class/NativeSwiftClassHasNativeWeakReferenceNoLeak") {
124123
expectNil(verifier)
125124
}
126125

127-
#if hasFeature(WeakLet)
128126
class NativeSwiftClassHasWeakLet {
129127
weak let weakProperty: AnyObject?
130128
let x: Int
@@ -207,7 +205,6 @@ mirrors.test("class/NativeSwiftClassHasNativeWeakLetReferenceNoLeak") {
207205
}
208206
expectNil(verifier)
209207
}
210-
#endif
211208

212209
#if _runtime(_ObjC)
213210

@@ -378,8 +375,6 @@ mirrors.test("struct/StructHasObjCClassBoundExistential") {
378375
print(extractedChild)
379376
}
380377

381-
#if hasFeature(WeakLet)
382-
383378
class NativeSwiftClassHasObjCClassBoundExistentialLet {
384379
weak let weakProperty: ObjCClassExistential?
385380
let x: Int
@@ -532,6 +527,4 @@ mirrors.test("struct/StructHasObjCClassBoundExistentialLet") {
532527

533528
#endif
534529

535-
#endif
536-
537530
runAllTests()

0 commit comments

Comments
 (0)