New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-11108] Conformance checking doesn't consider 'where' clause for vars #53503
Comments
With assertions:
Just to be clear, that overload won't be used to satisfy the requirement, because requirements are satisfied once at the time the conformance is declared. But the compiler shouldn't crash, of course. @swift-ci create |
Comment by Jorge Revuelta Herrero (JIRA) So that means that `string` should be declared on MyClass? |
If you want it to be used when calling through the protocol, yes. |
Comment by Jorge Revuelta Herrero (JIRA) I want to make use of the specializations when initializing MyClass when the concrete extension was available, but it seems that is not possible? protocol Example {
associatedtype Signed: SignedInteger
associatedtype SP: StringProtocol
var string: String { get }
}
extension Example {
var string: String {
return "Foo"
}
}
class MyClass<T: SignedInteger, S: StringProtocol>: Example {
typealias Signed = T
typealias SP = S
var _string: String!
init() {
_string = string
}
}
extension MyClass where T == Int, S == String {
var string: String {
return "Bar"
}
}
let myclass = MyClass<Int, String>()
print(myclass.string) // should be "Bar"
print(myclass._string) // would like to be "Bar" but it'll be "Foo" |
Swift only has three ways to get dynamic dispatch:
Everything else is chosen by the compiler through overload resolution, including "which implementation satisfies this protocol requirement". And since Swift, unlike C++, does not make copies of the code for different generic arguments (except as an optimization), |
Comment by Jorge Revuelta Herrero (JIRA) Which PR solved this? 🙂 |
Sorry, I did the wrong thing in JIRA. I meant to dupe it to an existing bug (still unresolved). |
Attachment: Download
Environment
macOS 10.15 beta 3
Xcode 11 beta 3 && Xcode 10.2
Swift 5.0, Swift 5.1 (master branch, 5.1 branch, Xcode built-in)
Additional Detail from JIRA
md5: 95afe6f0a7d84a0afa7fd3aa02cc1f82
duplicates:
Issue Description:
Executing the following code crashes the compiler on Xcode 10.2 using Swift 5.0 and on Xcode 11 beta 3, using three different snapshots (master branch, 5.1, Xcode's one):
The text was updated successfully, but these errors were encountered: