Skip to content

Commit 64a48d0

Browse files
committed
Update tests for strict @Lifetime type checking
1 parent 88a242f commit 64a48d0

File tree

53 files changed

+231
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+231
-139
lines changed

test/ASTGen/attrs.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ struct OpTest {
219219

220220
struct E {}
221221
struct NE : ~Escapable {}
222-
@lifetime(ne) func derive(_ ne: NE) -> NE { ne }
223-
@lifetime(borrow ne1, ne2) func derive(_ ne1: NE, _ ne2: NE) -> NE {
222+
@lifetime(copy ne) func derive(_ ne: NE) -> NE { ne }
223+
@lifetime(borrow ne1, copy ne2) func derive(_ ne1: NE, _ ne2: NE) -> NE {
224224
if (Int.random(in: 1..<100) < 50) { return ne1 }
225225
return ne2
226226
}
227227
@lifetime(borrow borrow) func testNameConflict(_ borrow: E) -> NE { NE() }
228-
@lifetime(result: source) func testTarget(_ result: inout NE, _ source: consuming NE) { result = source }
228+
@lifetime(result: copy source) func testTarget(_ result: inout NE, _ source: consuming NE) { result = source }
229229

230230
actor MyActor {
231231
nonisolated let constFlag: Bool = false

test/Generics/inverse_casting_availability.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %target-typecheck-verify-swift \
2+
// RUN: -enable-experimental-feature LifetimeDependence \
23
// RUN: -debug-diagnostic-names -target arm64-apple-macos14.4
34

5+
// REQUIRES: swift_feature_LifetimeDependence
6+
47
// REQUIRES: OS=macosx || OS=ios || OS=tvos || OS=watchOS || OS=xros
58

69
protocol P {}

test/Generics/inverse_conditional_conformance_copyable_and_escapable.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// RUN: %target-swift-frontend -typecheck -verify %s
1+
// RUN: %target-swift-frontend \
2+
// RUN: -enable-experimental-feature LifetimeDependence \
3+
// RUN: -typecheck -verify %s
4+
5+
// REQUIRES: swift_feature_LifetimeDependence
26

37
struct C_C1<T: ~Copyable>: ~Copyable {}
48
extension C_C1: Copyable where T: Copyable {}

test/Generics/inverse_conditional_conformance_restriction.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// RUN: %target-typecheck-verify-swift \
2+
// RUN: -enable-experimental-feature LifetimeDependence \
23
// RUN: -enable-experimental-feature SuppressedAssociatedTypes
34

5+
// REQUIRES: swift_feature_LifetimeDependence
46
// REQUIRES: swift_feature_SuppressedAssociatedTypes
57

68
protocol P {}

test/Generics/inverse_extension_signatures.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// RUN: %target-swift-frontend \
2+
// RUN: -enable-experimental-feature LifetimeDependence \
23
// RUN: -verify -typecheck %s -debug-generic-signatures \
34
// RUN: -debug-inverse-requirements 2>&1 | %FileCheck %s --implicit-check-not "error:"
45

6+
// REQUIRES: swift_feature_LifetimeDependence
57

68
// CHECK-LABEL: .Outer@
79
// CHECK: Generic signature: <A where A : Escapable>

test/Generics/inverse_generics.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ struct BuggerView<T: ~Copyable>: ~Escapable, Copyable {}
249249

250250
struct MutableBuggerView<T: ~Copyable>: ~Copyable, ~Escapable {}
251251

252+
@lifetime(mutRef: copy mutRef)
252253
func checkNominals(_ mutRef: inout MutableBuggerView<NC>,
253254
_ ref: BuggerView<NC>,
254255
_ intMutRef: borrowing MutableBuggerView<Int>,

test/Interop/C/swiftify-import/counted-by-noescape.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import CountedByNoEscapeClang
1414
// CHECK: @_alwaysEmitIntoClient public func complexExpr(_ len: Int{{.*}}, _ offset: Int{{.*}}, _ p: MutableSpan<Int{{.*}}>)
1515
// CHECK-NEXT: @_alwaysEmitIntoClient public func nonnull(_ p: MutableSpan<Int{{.*}}>)
1616
// CHECK-NEXT: @_alwaysEmitIntoClient public func nullUnspecified(_ p: MutableSpan<Int{{.*}}>)
17-
// CHECK-NEXT: @lifetime(p)
17+
// CHECK-NEXT: @lifetime(copy p)
1818
// CHECK-NEXT: @_alwaysEmitIntoClient public func returnLifetimeBound(_ len1: Int32, _ p: MutableSpan<Int32>) -> MutableSpan<Int32>
1919
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func returnPointer(_ len: Int{{.*}}) -> UnsafeMutableBufferPointer<Int{{.*}}>
2020
// CHECK-NEXT: @_alwaysEmitIntoClient public func shared(_ len: Int{{.*}}, _ p1: MutableSpan<Int{{.*}}>, _ p2: MutableSpan<Int{{.*}}>)

test/Interop/Cxx/class/safe-interop-mode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module Test {
2121
struct SWIFT_NONESCAPABLE View {
2222
__attribute__((swift_attr("@lifetime(immortal)")))
2323
View() : member(nullptr) {}
24-
__attribute__((swift_attr("@lifetime(p)")))
24+
__attribute__((swift_attr("@lifetime(copy p)")))
2525
View(const int *p [[clang::lifetimebound]]) : member(p) {}
2626
View(const View&) = default;
2727
private:

test/Interop/Cxx/stdlib/std-span-interface.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ import CxxStdlib
3535
// CHECK-NEXT: mutating func foo(_ s: std.{{.*}}span<__cxxConst<CInt>, _C{{.*}}_{{.*}}>)
3636
// CHECK-NEXT: }
3737
// CHECK: @_alwaysEmitIntoClient public func funcWithSafeWrapper(_ s: Span<CInt>)
38-
// CHECK-NEXT: @lifetime(s)
38+
// CHECK-NEXT: @lifetime(copy s)
3939
// CHECK-NEXT: @_alwaysEmitIntoClient public func funcWithSafeWrapper2(_ s: Span<CInt>) -> Span<CInt>
4040
// CHECK-NEXT: @lifetime(borrow v)
4141
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func funcWithSafeWrapper3(_ v: borrowing VecOfInt) -> Span<CInt>
42-
// CHECK-NEXT: @lifetime(p)
42+
// CHECK-NEXT: @lifetime(copy p)
4343
// CHECK-NEXT: @_alwaysEmitIntoClient public func mixedFuncWithSafeWrapper1(_ p: Span<Int32>) -> Span<CInt>
4444
// CHECK-NEXT: @lifetime(borrow v)
4545
// CHECK-NEXT: @_alwaysEmitIntoClient @_disfavoredOverload public func mixedFuncWithSafeWrapper2(_ v: borrowing VecOfInt, _ len: Int32) -> Span<Int32>

test/Macros/SwiftifyImport/CountedBy/PointerReturn.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func lifetimeDependentBorrow(_ p: borrowing UnsafePointer<CInt>, _ len1: CInt, _
2828
// CHECK-NEXT: func nonEscaping(_ len: CInt) -> UnsafeBufferPointer<CInt> {
2929
// CHECK-NEXT: return unsafe UnsafeBufferPointer<CInt> (start: nonEscaping(len), count: Int(len))
3030

31-
// CHECK: @_alwaysEmitIntoClient @lifetime(p)
31+
// CHECK: @_alwaysEmitIntoClient @lifetime(copy p)
3232
// CHECK-NEXT: func lifetimeDependentCopy(_ p: Span<CInt>, _ len2: CInt) -> Span<CInt> {
3333
// CHECK-NEXT: return unsafe Span<CInt> (_unsafeStart: p.withUnsafeBufferPointer { _pPtr in
3434
// CHECK-NEXT: return unsafe lifetimeDependentCopy(_pPtr.baseAddress!, CInt(exactly: p.count)!, len2)

0 commit comments

Comments
 (0)