From 22cdba4a59beb2bc95c564d4b11d3ed049e4d203 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 22 Jun 2025 23:21:13 -0400 Subject: [PATCH] Sema: Add missing test case for 63a5731da14c346b49b9d101d43f5cb156dfe46c --- .../bind_extensions_request_cycle.swift | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/Macros/bind_extensions_request_cycle.swift 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() } +}