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
swift-ci opened this issue
Nov 16, 2018
· 3 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1)
Target: x86_64-apple-darwin17.7.0
Additional Detail from JIRA
Votes
0
Component/s
Compiler
Labels
Bug, CompilerCrash
Assignee
None
Priority
Medium
md5: 7e265f036ada5e12b2d3f4f9ba4dce7f
duplicates:
SR-5581 Proper support for protocol 'where' clause with constraints on 'Self'
Issue Description:
Created a protocol that's constrained to a class type. Created an instance of the metatype of that protocol, then attempted to call init on that instance, which crashes the compiler.
If instead, I create a typealias combining the bare protocol (without constraints) and the type constraint, then I can call init on an instance of that typealias' metatype.
Example code:
import Foundation
// MARK: - Crashes
protocol ProtocolWithObjectA where Self: NSObject {
init(string: String)
}
final class ImplementationA: NSObject, ProtocolWithObjectA {
init(string: String) { super.init() }
}
let typeA: ProtocolWithObjectA.Type = ImplementationA.self
typeA.init(string: "") // Crash here
// MARK: - Works
protocol ProtocolB {
init(string: String)
}
typealias ProtocolWithObjectB = (ProtocolB & NSObject)
final class ImplementationB: NSObject, ProtocolB {
init(string: String) { super.init() }
}
let typeB: ProtocolWithObjectB.Type = ImplementationB.self
typeB.init(string: "")
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
Environment
macOS High Sierra (Version 10.13.6)
Xcode 10.0 (10A255)
Apple Swift version 4.2 (swiftlang-1000.11.37.1 clang-1000.11.45.1)
Target: x86_64-apple-darwin17.7.0
Additional Detail from JIRA
md5: 7e265f036ada5e12b2d3f4f9ba4dce7f
duplicates:
Issue Description:
Created a protocol that's constrained to a class type. Created an instance of the metatype of that protocol, then attempted to call init on that instance, which crashes the compiler.
If instead, I create a typealias combining the bare protocol (without constraints) and the type constraint, then I can call init on an instance of that typealias' metatype.
Example code:
Stack trace:
The text was updated successfully, but these errors were encountered: