Skip to content

[SR-11013] Not possible to specify conformances in protocol extension #53403

@johnno1962

Description

@johnno1962
Previous ID SR-11013
Radar None
Original Reporter @johnno1962
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels New Feature, LanguageFeatureRequest
Assignee @johnno1962
Priority Medium

md5: adaaec1870f21fa760ae6d8b2888a02b

Issue Description:

Protocol extensions are very powerful but it is not possible to specify a protocol the extension has made all nationals conforming to the protocol being extended conform to. In short I would have thought it would be useful to be able to do the following (for example):

extension FixedWidthInteger: ExpressibleByUnicodeScalarLiteral {
    public init(unicodeScalarLiteral value: Unicode.Scalar) {
      self = Self(value.value)
    }
}

The compiler is most of the way there already implementing the adding of members to a protocol available to all nominals conforming to the protocol. The only missing thing is being able to specify the conformance.

Metadata

Metadata

Assignees

Labels

compilerThe Swift compiler itselffeatureA feature request or implementationswift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposal

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions