|
| 1 | +// REQUIRES: concurrency |
| 2 | + |
| 3 | +// RUN: %empty-directory(%t) |
| 4 | + |
| 5 | +// RUN: %sourcekitd-test -req=interface-gen %s -- %s -target %target-triple -module-name MyModule | %FileCheck %s --check-prefix=SWIFTSOURCE |
| 6 | + |
| 7 | +// RUN: %target-swift-frontend -emit-module -module-name MyModule -o %t/MyModule.swiftmodule %s |
| 8 | +// RUN: %sourcekitd-test -req=interface-gen -module MyModule -- -target %target-triple -I %t | %FileCheck %s --check-prefix=SWIFTMODULE |
| 9 | +// RUN: %sourcekitd-test -req=doc-info -module MyModule -- -target %target-triple -I %t | %FileCheck %s --check-prefix=DOCINFO |
| 10 | + |
| 11 | +@propertyWrapper |
| 12 | +public struct OrLess { |
| 13 | + private var threshold: Int |
| 14 | + private var number: Int = 0 |
| 15 | + init(wrappedValue: Int, threshold: Int) { |
| 16 | + self.threshold = threshold |
| 17 | + self.wrappedValue = wrappedValue |
| 18 | + } |
| 19 | + public var wrappedValue: Int { |
| 20 | + get { return number } |
| 21 | + set { number = min(newValue, 12) } |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +@resultBuilder |
| 26 | +public struct IntBuilder { |
| 27 | + public static func buildBlock(_ val: Int) -> Int { val } |
| 28 | +} |
| 29 | + |
| 30 | +public struct TestStruct { |
| 31 | + |
| 32 | + @MainActor public func mainActorMethod() {} |
| 33 | + @MainActor(unsafe) public func mainActorUnsafeMethod() {} |
| 34 | + |
| 35 | + @OrLess(threshold: 12) public var twelveOrLess = 13 |
| 36 | + |
| 37 | + @IntBuilder public var intValue: Int { 1 } |
| 38 | +} |
| 39 | + |
| 40 | +// SWIFTSOURCE: public struct TestStruct { |
| 41 | +// SWIFTSOURCE: @MainActor public func mainActorMethod() |
| 42 | +// SWIFTSOURCE: @MainActor public func mainActorUnsafeMethod() |
| 43 | +// SWIFTSOURCE: @MyModule.OrLess public var twelveOrLess: Int { get set } |
| 44 | +// SWIFTSOURCE: @MyModule.IntBuilder public var intValue: Int { get } |
| 45 | +// SWIFTSOURCE: } |
| 46 | + |
| 47 | +// SWIFTMODULE: public struct TestStruct { |
| 48 | +// SWIFTMODULE: @MainActor public func mainActorMethod() |
| 49 | +// SWIFTMODULE: @MainActor public func mainActorUnsafeMethod() |
| 50 | +// SWIFTMODULE: @MyModule.OrLess public var twelveOrLess: Int |
| 51 | +// SWIFTMODULE: @MyModule.IntBuilder public var intValue: Int { get } |
| 52 | +// SWIFTMODULE: } |
| 53 | + |
| 54 | +// DOCINFO: struct TestStruct { |
| 55 | +// DOCINFO: @MainActor func mainActorMethod() |
| 56 | +// DOCINFO: @MainActor func mainActorUnsafeMethod() |
| 57 | +// DOCINFO: @MyModule.OrLess var twelveOrLess: Int |
| 58 | +// DOCINFO: @MyModule.IntBuilder var intValue: Int { get } |
| 59 | +// DOCINFO: } |
0 commit comments