File tree Expand file tree Collapse file tree 2 files changed +65
-2
lines changed Expand file tree Collapse file tree 2 files changed +65
-2
lines changed Original file line number Diff line number Diff line change @@ -3159,8 +3159,27 @@ static bool usesFeatureFlowSensitiveConcurrencyCaptures(Decl *decl) {
3159
3159
}
3160
3160
3161
3161
static bool usesFeatureMoveOnly (Decl *decl) {
3162
- if (auto nominal = dyn_cast<NominalTypeDecl>(decl))
3163
- return nominal->isMoveOnly ();
3162
+ if (auto *extension = dyn_cast<ExtensionDecl>(decl)) {
3163
+ if (auto *nominal = extension->getSelfNominalTypeDecl ())
3164
+ if (nominal->isMoveOnly ())
3165
+ return true ;
3166
+ }
3167
+
3168
+ if (auto value = dyn_cast<ValueDecl>(decl)) {
3169
+ if (value->isMoveOnly ())
3170
+ return true ;
3171
+
3172
+ // Check for move-only types in the types of this declaration.
3173
+ if (Type type = value->getInterfaceType ()) {
3174
+ bool hasMoveOnly = type.findIf ([](Type type) {
3175
+ return type->isPureMoveOnly ();
3176
+ });
3177
+
3178
+ if (hasMoveOnly)
3179
+ return true ;
3180
+ }
3181
+ }
3182
+
3164
3183
return false ;
3165
3184
}
3166
3185
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-emit-module-interface(%t/Library.swiftinterface) %s -module-name Library -enable-experimental-feature MoveOnly
3
+ // RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -I %t
4
+ // RUN: %FileCheck %s < %t/Library.swiftinterface
5
+
6
+ // this test makes sure that decls containing a move-only type are guarded by the $MoveOnly feature flag
7
+
8
+ // CHECK: swift-module-flags-ignorable: -enable-experimental-feature MoveOnly
9
+
10
+ // CHECK: #if compiler(>=5.3) && $MoveOnly
11
+ // CHECK-NEXT: @_moveOnly public struct MoveOnlyStruct {
12
+
13
+ // CHECK: #if compiler(>=5.3) && $MoveOnly
14
+ // CHECK-NEXT: @_moveOnly public enum MoveOnlyEnum {
15
+
16
+ // CHECK: #if compiler(>=5.3) && $MoveOnly
17
+ // CHECK-NEXT: public func someFn() -> Library.MoveOnlyEnum
18
+
19
+ // CHECK: public class What {
20
+ // CHECK: #if compiler(>=5.3) && $MoveOnly
21
+ // CHECK-NEXT: public func diamonds(_ f: (borrowing Library.MoveOnlyStruct) -> Swift.Int)
22
+
23
+ // CHECK: #if compiler(>=5.3) && $MoveOnly
24
+ // CHECK-NEXT: extension Library.MoveOnlyStruct {
25
+
26
+ @_moveOnly public struct MoveOnlyStruct {
27
+ let x = 0
28
+ }
29
+
30
+ @_moveOnly public enum MoveOnlyEnum {
31
+ case depth
32
+ }
33
+
34
+ public func someFn( ) -> MoveOnlyEnum { return . depth }
35
+
36
+ public class What {
37
+ public func diamonds( _ f: ( borrowing MoveOnlyStruct ) -> Int ) { }
38
+ }
39
+
40
+ public extension MoveOnlyStruct {
41
+ func who( ) { }
42
+ }
43
+
44
+
You can’t perform that action at this time.
0 commit comments