SwiftSemantics Documentation Beta

Structure Extension

public struct Extension: Declaration, Hashable, Codable

An extension declaration.

%3 Extension Extension Codable Codable Extension->Codable CustomStringConvertible CustomStringConvertible Extension->CustomStringConvertible ExpressibleBySyntax ExpressibleBySyntax Extension->ExpressibleBySyntax Hashable Hashable Extension->Hashable Declaration Declaration Extension->Declaration

Conforms To

Declaration

A Swift declaration.

ExpressibleBySyntax

A type that can be initialized with a Swift syntax node.

Codable
CustomStringConvertible
Hashable

Initializers

init(_:​)

public init(_ node: ExtensionDeclSyntax)

Creates an instance initialized with the given syntax node.

Properties

attributes

let attributes: [Attribute]

The declaration attributes.

modifiers

let modifiers: [Modifier]

The declaration modifiers.

keyword

let keyword: String

The declaration keyword ("extension").

extended​Type

let extendedType: String

The name of the type extended by the extension.

inheritance

let inheritance: [String]

A list of protocol names inherited by the extended type.

For example, the following extension on structure S has an inheritance of ["P", "Q"]:

struct S {}
protocol P {}
protocol Q {}
extension S: P, Q {}

generic​Requirements

let genericRequirements: [GenericRequirement]

The generic parameter requirements for the declaration.

For example, the following conditional extension on structure S has a single requirement that its generic parameter identified as "T" conforms to the type identified as "Hahable":

struct S<T> {}
extension S where T: Hashable {}

description

var description: String