Skip to content

ProtocolDescriptor

tevelee edited this page Jul 25, 2026 · 3 revisions

ProtocolDescriptor

A protocol descriptor that describes some protocol context.

public struct ProtocolDescriptor: ContextDescriptor, LayoutWrapper 

ABI Stability: Stable since the following

| macOS | iOS/tvOS | watchOS | Linux | Windows |
|-------|----------|---------|-------|---------|
| 10.14 | 12.2     | 5.2     | NA    | NA      |

Inheritance

ContextDescriptor, LayoutWrapper

Properties

ptr

Backing context descriptor pointer.

public let ptr: UnsafeRawPointer

protocolFlags

The specific flags that describe a protocol descriptor.

public var protocolFlags: Flags 

name

The name of this protocol.

public var name: String 

numRequirementsInSignature

The number of generic requirements in this protocol's signature.

public var numRequirementsInSignature: Int 

numRequirements

The number of protocol requirements this protocol defines.

public var numRequirements: Int 

associatedTypeNames

A string of all associatedtype names.

public var associatedTypeNames: String 

requirementSignature

An array of all the generic requirements in this protocol's signature.

public var requirementSignature: [GenericRequirementDescriptor] 

requirements

An array of all the protocol requirements this protocol defines.

public var requirements: [ProtocolRequirement] 

associatedTypeNameList

The names of this protocol's associated types in declaration order.

public var associatedTypeNameList: [String] 

Methods

associatedTypeWitness(named:conformingType:witnessTable:)

Resolves the metadata bound to an associated type for a conformance.

public func associatedTypeWitness(
    named name: String,
    conformingType: Metadata,
    witnessTable: WitnessTable
  ) -> Metadata? 

Parameters

  • name: The associated type name, such as "Element".
  • conformingType: Metadata for the conforming type.
  • witnessTable: The conformance's witness table.

Returns

The associated type's metadata, or nil if this descriptor does not define name or the required witness is unavailable.

associatedConformanceWitness(ofAssociatedType:to:conformingType:witnessTable:)

Resolves the witness table proving that an associated type conforms to targetProtocol for a particular conformance.

public func associatedConformanceWitness(
    ofAssociatedType associatedTypeName: String,
    to targetProtocol: ProtocolDescriptor,
    conformingType: Metadata,
    witnessTable: WitnessTable
  ) -> WitnessTable? 

The protocol requirement signature and associated-conformance access requirements must have a one-to-one ordering. When a refining protocol does not meet that ABI shape, this method fails closed with nil.

Types
Protocols
Global Typealiases
Global Variables
Global Functions

Clone this wiki locally