Files
swift-mirror/test/ModuleInterface/moveonly_interface_flag.swift
Kavon Farvardin ee819c80a9 Build support for ~Copyable atop @_moveOnly
We parse `~Copyable` in an inheritance clause of enum and
struct decls as a synonym for the `@_moveOnly` attribute
being added to that decl. This completely side-steps the
additional infrastructure for generalized suppressed
conformances in favor of a minimal solution. One benefit of
this minimal solution is that it doesn't risk introducing
any back-compat issues with older compilers or stdlibs.

The trade-off is that we're more committed to supporting
`@_moveOnly` in compiled modules in the future. In fact,
this change does not deprecate `@_moveOnly` in any way.

resolves rdar://106775103
2023-05-01 14:36:39 -07:00

55 lines
1.6 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-emit-module-interface(%t/Library.swiftinterface) %s -module-name Library
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -I %t
// RUN: %FileCheck %s < %t/Library.swiftinterface
// this test makes sure that decls containing a move-only type are guarded by the $MoveOnly feature flag
// CHECK: #if compiler(>=5.3) && $MoveOnly
// CHECK-NEXT: @_moveOnly public struct MoveOnlyStruct {
// CHECK: #if compiler(>=5.3) && $MoveOnly
// CHECK-NEXT: @_moveOnly public struct MoveOnlyStructSupp {
// CHECK: #if compiler(>=5.3) && $MoveOnly
// CHECK-NEXT: @_moveOnly public enum MoveOnlyEnum {
// CHECK: #if compiler(>=5.3) && $MoveOnly
// CHECK-NEXT: @_moveOnly public enum MoveOnlyEnumSupp {
// CHECK: #if compiler(>=5.3) && $MoveOnly
// CHECK-NEXT: public func someFn() -> Library.MoveOnlyEnum
// CHECK: public class What {
// CHECK: #if compiler(>=5.3) && $MoveOnly
// CHECK-NEXT: public func diamonds(_ f: (borrowing Library.MoveOnlyStruct) -> Swift.Int)
// CHECK: #if compiler(>=5.3) && $MoveOnly
// CHECK-NEXT: extension Library.MoveOnlyStruct {
@_moveOnly public struct MoveOnlyStruct {
let x = 0
}
public struct MoveOnlyStructSupp: ~Copyable {
let x = 0
}
@_moveOnly public enum MoveOnlyEnum {
case depth
}
public enum MoveOnlyEnumSupp: ~Copyable {
case depth
}
public func someFn() -> MoveOnlyEnum { return .depth }
public class What {
public func diamonds(_ f: (borrowing MoveOnlyStruct) -> Int) {}
}
public extension MoveOnlyStruct {
func who() {}
}