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 @@ -3163,8 +3163,27 @@ static bool usesFeatureFlowSensitiveConcurrencyCaptures(Decl *decl) {
3163
3163
}
3164
3164
3165
3165
static bool usesFeatureMoveOnly (Decl *decl) {
3166
- if (auto nominal = dyn_cast<NominalTypeDecl>(decl))
3167
- return nominal->isMoveOnly ();
3166
+ if (auto *extension = dyn_cast<ExtensionDecl>(decl)) {
3167
+ if (auto *nominal = extension->getSelfNominalTypeDecl ())
3168
+ if (nominal->isMoveOnly ())
3169
+ return true ;
3170
+ }
3171
+
3172
+ if (auto value = dyn_cast<ValueDecl>(decl)) {
3173
+ if (value->isMoveOnly ())
3174
+ return true ;
3175
+
3176
+ // Check for move-only types in the types of this declaration.
3177
+ if (Type type = value->getInterfaceType ()) {
3178
+ bool hasMoveOnly = type.findIf ([](Type type) {
3179
+ return type->isPureMoveOnly ();
3180
+ });
3181
+
3182
+ if (hasMoveOnly)
3183
+ return true ;
3184
+ }
3185
+ }
3186
+
3168
3187
return false ;
3169
3188
}
3170
3189
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