mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Use this to define the macro location rather than the "host" dir (which is actually for the build and not the host). Furthermore, on Windows, the build dir is /usr/lib/swift as the host content is in the SDK. This prepares the tests for Windows.
30 lines
849 B
Swift
30 lines
849 B
Swift
// REQUIRES: swift_swift_parser, executable_test
|
|
|
|
// RUN: %target-run-simple-swift(-Xfrontend -plugin-path -Xfrontend %swift-plugin-dir -emit-tbd -emit-tbd-path %t.tbd)
|
|
|
|
import Swift
|
|
|
|
@attached(member, names: named(RawValue), named(rawValue), named(`init`), arbitrary)
|
|
@attached(extension, conformances: OptionSet)
|
|
public macro OptionSet<RawType>() =
|
|
#externalMacro(module: "SwiftMacros", type: "OptionSetMacro")
|
|
|
|
@OptionSet<UInt8>
|
|
struct ShippingOptions {
|
|
private enum Options: Int {
|
|
case nextDay
|
|
case secondDay
|
|
case priority
|
|
case standard
|
|
}
|
|
|
|
static let express: ShippingOptions = [.nextDay, .secondDay]
|
|
static let all: ShippingOptions = [.express, .priority, .standard]
|
|
}
|
|
|
|
let options = ShippingOptions.express
|
|
assert(options.contains(.nextDay))
|
|
assert(options.contains(.secondDay))
|
|
assert(!options.contains(.standard))
|
|
|