mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
SE-390 concluded with choosing the keyword discard rather than forget for the statement that disables the deinit of a noncopyable type. This commit adds parsing support for `discard self` and adds a deprecation warning for `_forget self`. rdar://108859077
29 lines
1.3 KiB
Swift
29 lines
1.3 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-emit-module-interface(%t/Library.swiftinterface) %s -module-name Library -verify
|
|
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -I %t
|
|
// RUN: %FileCheck %s < %t/Library.swiftinterface
|
|
|
|
// This test makes sure that discard and _forget are emitted correctly in the
|
|
// interfaces. We expect that if you use the old name _forget, you'll get that
|
|
// in the interface file.
|
|
|
|
// CHECK: @_alwaysEmitIntoClient public consuming func AEIC_discard() { discard self }
|
|
// CHECK: @inlinable public consuming func inlinable_discard() { discard self }
|
|
|
|
// CHECK: @_alwaysEmitIntoClient public consuming func AEIC_forget() { _forget self }
|
|
// CHECK: @inlinable public consuming func inlinable_forget() { _forget self }
|
|
|
|
public struct MoveOnlyStruct: ~Copyable {
|
|
let x = 0
|
|
|
|
@_alwaysEmitIntoClient public consuming func AEIC_discard() { discard self }
|
|
@inlinable public consuming func inlinable_discard() { discard self }
|
|
|
|
@_alwaysEmitIntoClient public consuming func AEIC_forget() { _forget self }
|
|
// expected-warning@-1 {{'_forget' keyword is deprecated and will be removed soon; use 'discard' instead}}
|
|
@inlinable public consuming func inlinable_forget() { _forget self }
|
|
// expected-warning@-1 {{'_forget' keyword is deprecated and will be removed soon; use 'discard' instead}}
|
|
|
|
deinit {}
|
|
}
|