Skip to content

Commit 7935ced

Browse files
committed
[addr-move-function] Added tests for lets for partial_apply to make sure that we properly error on them.
(cherry picked from commit e6a9ac3)
1 parent c920101 commit 7935ced

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

test/SILOptimizer/move_function_kills_copyable_addressonly_lets.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,16 @@ public func castTestIfLet2(_ x : __owned EnumWithKlass) { // expected-error {{'x
376376
print("no")
377377
}
378378
}
379+
380+
/////////////////////////
381+
// Partial Apply Tests //
382+
/////////////////////////
383+
384+
// Emit a better error here. At least we properly error.
385+
public func partialApplyTest<T>(_ x: __owned T) { // expected-error {{'x' used after being moved}}
386+
let _ = _move(x) // expected-note {{move here}}
387+
let f = { // expected-note {{use here}}
388+
nonConsumingUse(x)
389+
}
390+
f()
391+
}

test/SILOptimizer/move_function_kills_copyable_values.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,16 @@ public func castTestIfLet2(_ x : __owned EnumWithKlass) { // expected-error {{'x
350350
print("no")
351351
}
352352
}
353+
354+
/////////////////////////
355+
// Partial Apply Tests //
356+
/////////////////////////
357+
358+
// Emit a better error here. At least we properly error.
359+
public func partialApplyTest(_ x: __owned Klass) { // expected-error {{'x' used after being moved}}
360+
let _ = _move(x) // expected-note {{move here}}
361+
let f = { // expected-note {{use here}}
362+
print(x)
363+
}
364+
f()
365+
}

0 commit comments

Comments
 (0)