Files
swift-mirror/test/APIJSON/extension-conformance-access.swift
Zixu Wang 1b3bdb992e [APIGen] Check extended type to determine ExtensionDecl SPIs (#93245)
Symbols attributed to an `ExtensionDecl`, for example conformance
descriptors and witness tables, should not be more visible than the
extended nominal type.
Check to see if the extended nominal is SPI for these symbols.

Resolves rdar://189935376
Assisted-By: Claude Code (claude-opus-5-5)

<!--
If this pull request is targeting a release branch, please fill out the
following form:

https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1

Otherwise, replace this comment with a description of your changes and
rationale. Provide links to external references/discussions if
appropriate.
If this pull request resolves any GitHub issues, link them like so:

  Resolves <link to issue>, resolves <link to another issue>.

For more information about linking a pull request to an issue, see:

https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->

<!--
Before merging this pull request, you must run the Swift continuous
integration tests.
For information about triggering CI builds via @swift-ci, see:

https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci

Thank you for your contribution to Swift!
-->
2026-10-14 16:10:34 -07:00

58 lines
2.4 KiB
Swift

// REQUIRES: OS=macosx
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/ModuleCache)
// RUN: %target-swift-frontend %s -typecheck -parse-as-library -enable-library-evolution -module-name MyModule -package-name MyModule -swift-version 5 -library-level api -emit-api-descriptor-path %t/api.json
// RUN: %validate-json %t/api.json | %FileCheck %s
public protocol PublicProto {}
public protocol PublicProtoWithReq { func requirement() }
// A package type's conformances are package-level, whether declared inline or in
// an extension, so their symbols must be SPI.
package struct PackageStruct {}
extension PackageStruct: PublicProto {}
extension PackageStruct: PublicProtoWithReq {
package func requirement() {}
}
package struct PackageInline: PublicProto {}
// Nested in a package type: effectively package.
package struct PackageOuter {
public struct Inner {}
}
extension PackageOuter.Inner: PublicProto {}
// A public type's conformance to a public protocol is API.
public struct PublicStruct {}
extension PublicStruct: PublicProto {}
// An extension of an `@_spi` type is SPI as well.
@_spi(Private) public struct SPIStruct {}
extension SPIStruct: PublicProto {}
// CHECK: "name": "_$s8MyModule12PackageOuterV5InnerVAA11PublicProtoAAMc",
// CHECK-NEXT: "access": "private",
// CHECK: "name": "_$s8MyModule12PackageOuterV5InnerVAA11PublicProtoAAWP",
// CHECK-NEXT: "access": "private",
// CHECK: "name": "_$s8MyModule12PublicStructVAA0C5ProtoAAMc",
// CHECK-NEXT: "access": "public",
// CHECK: "name": "_$s8MyModule12PublicStructVAA0C5ProtoAAWP",
// CHECK-NEXT: "access": "public",
// CHECK: "name": "_$s8MyModule13PackageInlineVAA11PublicProtoAAMc",
// CHECK-NEXT: "access": "private",
// CHECK: "name": "_$s8MyModule13PackageInlineVAA11PublicProtoAAWP",
// CHECK-NEXT: "access": "private",
// CHECK: "name": "_$s8MyModule13PackageStructVAA11PublicProtoAAMc",
// CHECK-NEXT: "access": "private",
// CHECK: "name": "_$s8MyModule13PackageStructVAA11PublicProtoAAWP",
// CHECK-NEXT: "access": "private",
// CHECK: "name": "_$s8MyModule13PackageStructVAA18PublicProtoWithReqAAMc",
// CHECK-NEXT: "access": "private",
// CHECK: "name": "_$s8MyModule13PackageStructVAA18PublicProtoWithReqAAWP",
// CHECK-NEXT: "access": "private",
// CHECK: "name": "_$s8MyModule9SPIStructVAA11PublicProtoAAMc",
// CHECK-NEXT: "access": "private",
// CHECK: "name": "_$s8MyModule9SPIStructVAA11PublicProtoAAWP",
// CHECK-NEXT: "access": "private",