diff --git a/test/Macros/bind_extensions_request_cycle.swift b/test/Macros/bind_extensions_request_cycle.swift new file mode 100644 index 0000000000000..8454b27b6b345 --- /dev/null +++ b/test/Macros/bind_extensions_request_cycle.swift @@ -0,0 +1,29 @@ +// RUN: %target-typecheck-verify-swift %s + +@attached(member) @attached(peer) +public macro Foo(_: any P) = #externalMacro(module: "FooMacros", type: "FooMacro") +// expected-warning@-1 {{external macro implementation type 'FooMacros.FooMacro' could not be found for macro 'Foo'; plugin for module 'FooMacros' not found}} +// expected-note@-2 2 {{'Foo' declared here}} + +public protocol P {} + +@Foo(S.s) +struct A { +// expected-error@-1 2 {{external macro implementation type 'FooMacros.FooMacro' could not be found for macro 'Foo'; plugin for module 'FooMacros' not found}} + func a() {} +} + +extension A { + struct Nested {} +} + +// Binding this extension must not trigger macro expansion, because that +// performs a qualified lookup of S.s, which fails because the extension +// of P declared below has not been bound yet. +extension A.Nested {} + +struct S: P {} + +extension P where Self == S { + static var s: Self { Self() } +}