You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-9275 Crash when calling init on a protocol's metatype where the protocol is constrained to a type
SR-9477 Dynamic-stack-buffer-overflow caused by where clause on protocol
SR-7331 Diagnose protocol 'where' clause with constraints on 'Self'
Issue Description:
The following code fails to compile in a swift playground:
protocol Toggling where Self: Equatable {
static var all: [Self] { get }
func toggled() -> Self
}
extension Toggling {
func toggled() -> Self {
let current = Self.all.index(of: self) ?? 0
let next = (current + 1) % Self.all.count
return Self.all[next]
}
}
Changing to simple conformance makes it work:
protocol Toggling : Equatable { .... }
The two should be equivalent.
Also, putting the constraint of Self: Equatable on the protocol extension (and removing it from the protocol declaration) also makes it work.
Having the Self requirement on both the protocol definition and extension correctly identifies that the constraint is redundant but also fails to compile.
The text was updated successfully, but these errors were encountered:
Module::lookupConformance() calls ProtocolDecl::inheritsFrom() which calls NominalTypeDecl::getLocalConformances(), which doesn't know how to check the where clause or requirement signature, it just looks at the inheritance clause.
Environment
Xcode Version 9.0 beta 4 (9M189t), Playground, MacBook Pro 10.12.6
Additional Detail from JIRA
md5: 765079ddd3f018ba4c61239ed7475537
is duplicated by:
where
restriction doesn't apply: class
semanticswhere
restriction is not substitutableIssue Description:
The following code fails to compile in a swift playground:
Changing to simple conformance makes it work:
The two should be equivalent.
Also, putting the constraint of Self: Equatable on the protocol extension (and removing it from the protocol declaration) also makes it work.
Having the Self requirement on both the protocol definition and extension correctly identifies that the constraint is redundant but also fails to compile.
The text was updated successfully, but these errors were encountered: