Files
swift-mirror/test/Macros/Inputs/macro_library.swift
Doug Gregor ac448b865b [Clang importer] Don't cache swift_attr source files that have CustomAttrs with arguments
Since we can't do a proper "deep" clone of expression nodes, cloning
such a CustomAttr is necessarily shallow. In such cases, don't cache
the swift_attr source files at all, so we get fresh attribute nodes
for each such usage.
2024-12-04 15:24:00 -08:00

69 lines
2.3 KiB
Swift

public protocol Observable {}
public protocol Observer<Subject> {
associatedtype Subject: Observable
}
public struct ObservationRegistrar<Subject: Observable> {
public init() {}
public func addObserver(_ observer: some Observer<Subject>) {}
public func removeObserver(_ observer: some Observer<Subject>) {}
public func beginAccess<Value>(_ keyPath: KeyPath<Subject, Value>) {}
public func beginAccess() {}
public func endAccess() {}
public func register<Value>(observable: Subject, willSet: KeyPath<Subject, Value>, to: Value) {}
public func register<Value>(observable: Subject, didSet: KeyPath<Subject, Value>) {}
}
@attached(
member,
names: named(_registrar), named(addObserver), named(removeObserver), named(withTransaction), named(Storage), named(_storage)
)
@attached(memberAttribute)
@attached(extension, conformances: Observable)
public macro Observable() = #externalMacro(module: "MacroDefinition", type: "ObservableMacro")
@attached(accessor)
public macro ObservableProperty() = #externalMacro(module: "MacroDefinition", type: "ObservablePropertyMacro")
@attached(peer, names: overloaded)
public macro addCompletionHandler() = #externalMacro(module: "MacroDefinition", type: "AddCompletionHandler")
@attached(peer, names: suffixed(Builder))
public macro AddClassReferencingSelf() = #externalMacro(module: "MacroDefinition", type: "AddClassReferencingSelfMacro")
@attached(peer, names: named(value))
public macro declareVarValuePeer() = #externalMacro(module: "MacroDefinition", type: "VarValueMacro")
@propertyWrapper
public struct declareVarValuePeerShadowed {
public var wrappedValue: Int
public init(wrappedValue: Int) {
self.wrappedValue = wrappedValue
}
}
@attached(peer, names: named(value))
public macro declareVarValuePeerShadowed() = #externalMacro(module: "MacroDefinition", type: "VarValueMacro")
@attached(peer, names: overloaded)
public macro AddAsync() = #externalMacro(module: "MacroDefinition", type: "AddAsyncMacro")
@attached(peer, names: overloaded)
public macro AddAsyncFinal() = #externalMacro(module: "MacroDefinition", type: "AddAsyncMacro")
public enum Something {
case something
}
@attached(peer, names: overloaded)
public macro AcceptedDotted(_: Something) = #externalMacro(module: "MacroDefinition", type: "EmptyPeerMacro")