Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Extension

Mattt edited this page Aug 2, 2020 · 8 revisions

Extension

An extension declaration.

public struct Extension:​ Declaration, Hashable, Codable

Inheritance

Codable, CustomStringConvertible, Declaration, ExpressibleBySyntax, Hashable

Initializers

init(_:​)

Creates an instance initialized with the given syntax node.

public init(_ node:​ ExtensionDeclSyntax)

Properties

attributes

The declaration attributes.

let attributes:[Attribute]

modifiers

The declaration modifiers.

let modifiers:[Modifier]

keyword

The declaration keyword ("extension").

let keyword:​ String

extendedType

The name of the type extended by the extension.

let extendedType:​ String

inheritance

A list of protocol names inherited by the extended type.

let inheritance:[String]

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

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

genericRequirements

The generic parameter requirements for the declaration.

let genericRequirements:[GenericRequirement]

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
Clone this wiki locally