Prevent #if in @abi in module interfaces

When a language feature is used inside an `@abi` attribute, we should behave as though it was used on its counterpart. This was already half-implemented—we ensured the counterpart would use the feature—but we didn’t make the ABI decl aware that the counterpart was its parent for feature detection purposes. As a result, we would print `#if` inside the `@abi` attribute, which isn’t valid.
This commit is contained in:
Becca Royal-Gordon
2025-04-17 16:49:04 -07:00
parent d59d219078
commit ae936ac384
2 changed files with 19 additions and 1 deletions

View File

@@ -85,6 +85,20 @@ public struct MutatingTest {
@abi(func abiSpiFunc())
@_spi(spiGroup) public func abiSpiFunc() {}
// We should print feature guards outside, but not inside, an @abi attribute.
@abi(func sendingABI() -> sending Any?)
public func sendingABI() -> Any? { nil }
// CHECK: #if {{.*}} && $ABIAttribute
// CHECK: @abi(func sendingABI() -> sending Any?)
// CHECK: public func sendingABI() -> Any?
// CHECK: #elseif {{.*}} && $SendingArgsAndResults
// CHECK: @_silgen_name("$s5attrs10sendingABIypSgyF")
// CHECK: public func sendingABI() -> Any?
// CHECK: #else
// CHECK: @_silgen_name("$s5attrs10sendingABIypSgyF")
// CHECK: public func sendingABI() -> Any?
// CHECK: #endif
@concurrent
public func testExecutionConcurrent() async {}
// CHECK: @concurrent public func testExecutionConcurrent() async