Files
swift-mirror/test/ModuleInterface/moveonly_interface_flag.swift
Michael Gottesman d0938a906f [move-only] Ban resilient noncopyable types.
One can still in resilient frameworks have noncopyable frozen types.

This means that one cannot make a noncopyable:

1. Full resilient public type.
2. @usableFromInline type.

NOTE: One can still use a frozen noncopyable type as a usableFromInline class
field. I validated in the attached tests that we get the correct code
generation.

I also eliminated a small bug in TypeCheckDeclPrimary where we weren't using a
requestified attr check and instead were checking directly.

rdar://111125845
2023-06-21 16:57:44 -07:00

55 lines
1.7 KiB
Swift

7// RUN: %empty-directory(%t)
// RUN: %target-swift-emit-module-interface(%t/Library.swiftinterface) %s -module-name Library -enable-experimental-feature MoveOnlyResilientTypes
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -I %t -enable-experimental-feature MoveOnlyResilientTypes
// 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() {}
}