File tree Expand file tree Collapse file tree 4 files changed +94
-0
lines changed Expand file tree Collapse file tree 4 files changed +94
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ // FIXME: make this test work when this enum is move-only
3+ public enum Descriptor {
4+ case stdout
5+ case stderr
6+ case other( Int )
7+
8+ public func message( ) -> String { return " hello world " }
9+ }
10+
11+ @_moveOnly
12+ public struct File {
13+
14+ #if SYNTHESIZE_ACCESSORS
15+ public var fd : Descriptor = . other( 1337 )
16+ #else
17+ private var _fd : Descriptor = . other( 1337 )
18+ public var fd : Descriptor {
19+ _modify { yield & _fd }
20+ _read { yield _fd }
21+ }
22+ #endif
23+
24+ public init ( ) { }
25+ }
26+
27+ public class FileHandle {
28+ #if SYNTHESIZE_ACCESSORS
29+ public var file : File = File ( )
30+ #else
31+ private var _file : File = File ( )
32+ public var file : File {
33+ _modify { yield & _file }
34+ _read { yield _file }
35+ }
36+ #endif
37+
38+ #if SYNTHESIZE_ACCESSORS
39+ public let immutableFile : File = File ( )
40+ #else
41+ public var immutableFile : File {
42+ return File ( ) // still immutable, but now generated fresh each time!
43+ }
44+ #endif
45+
46+ public init ( ) { }
47+ }
Original file line number Diff line number Diff line change 1+
2+ public class Message { var s : String = " hello " }
3+
4+ @_moveOnly
5+ public struct FileDescriptor {
6+ public var x : Int = 0
7+ public var msg : Message = Message ( )
8+ }
9+
10+ public class FileHandle {
11+ var file : FileDescriptor = FileDescriptor ( )
12+ }
13+
Original file line number Diff line number Diff line change 1+ // RUN: %empty-directory(%t)
2+
3+ // FIXME: should work without syntize accessors too
4+ // RUN: %target-swift-frontend -DSYNTHESIZE_ACCESSORS -enable-library-evolution -module-name Hello -emit-module -o %t/Hello.swiftmodule -emit-module-interface-path %t/Hello.swiftinterface %S/Inputs/moveonly_simple.swift -enable-experimental-move-only
5+
6+ // rdar://106164128
7+ // XFAIL: *
8+
9+ // TODO: finish this test by verifying the interface with FileCheck
Original file line number Diff line number Diff line change 1+ // RUN: %empty-directory(%t)
2+
3+ // >> first try when no library evolution is specified
4+ // RUN: %target-swift-frontend -DSYNTHESIZE_ACCESSORS -enable-experimental-move-only -emit-module -o %t/Hello.swiftmodule %S/Inputs/moveonly_api.swift
5+ // RUN: %target-swift-frontend -emit-sil -sil-verify-all -enable-experimental-move-only -I %t %s > /dev/null
6+
7+ // >> now again with library evolution; we expect the same result.
8+ // FIXME: move checker doesn't like it when you specify library evolution
9+ // RUN: %target-swift-frontend -DSYNTHESIZE_ACCESSORS -enable-library-evolution -enable-experimental-move-only -emit-module -o %t/Hello.swiftmodule %S/Inputs/moveonly_api.swift
10+ // RUN: %target-swift-frontend -emit-sil -sil-verify-all -enable-experimental-move-only -I %t %s > /dev/null
11+
12+ // FIXME: ideally this would also try executing the program rather than just generating SIL
13+
14+ // FIXME: make this test work when we're not synthesizing the accessors
15+
16+ // rdar://106164128
17+ // XFAIL: *
18+
19+ import Hello
20+
21+ func simpleTest( ) {
22+ let handle = FileHandle ( )
23+ let msg = handle. file. fd. message ( )
24+ print ( msg)
25+ }
You can’t perform that action at this time.
0 commit comments