Files
swift-mirror/test/Macros/accessor_has_storage_cycle.swift
Doug Gregor a72fb83034 Requestify AbstractStorageDecl::hasStorage().
The `hasStorage()` computation is used in many places to determine the
signatures of other declarations. It currently needs to expand accessor
macros, which causes a number of cyclic references. Provide a
simplified request to determine `hasStorage` without expanding or
resolving macros, breaking a common pattern of cycles when using
macros.

Fixes rdar://109668383.
2023-06-10 08:28:06 -07:00

22 lines
704 B
Swift

// REQUIRES: swift_swift_parser
// RUN: %target-typecheck-verify-swift -swift-version 5 -swift-version 5
struct Predicate<T> { }
@freestanding(expression)
macro Predicate<T>(_ body: (T) -> Void) -> Predicate<T> = #externalMacro(module: "A", type: "B")
// expected-warning@-1{{could not be found}}
@attached(accessor)
@attached(peer)
macro Foo<T>(filter: Predicate<T>) = #externalMacro(module: "A", type: "B")
// expected-warning@-1{{could not be found}}
// expected-note@-2 2{{declared here}}
struct Content {
@Foo(filter: #Predicate<Bool> { $0 == true }) var foo: Bool = true
//expected-error@-1 2{{could not be found for macro}}
// expected-warning@-2{{result of operator '==' is unused}}
}