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-3204] Stored value type does not match pointer operand type! #45792
Comments
cc @bob-wilson |
aschwaighofer@apple.com (JIRA User) Arnold is also looking at something like this. |
Comment by Myke Olson (JIRA) @swift-ci create |
Does not reproduce with the Nov 11 [snapshot | https://swift.org/download/#snapshots]. There have been archetype builder fixes going in since the last release that could explain that this is fixed. |
I have reproduced this and can now say for certain that this is cause by a bug similar to the one fixed by Doug in #5815 The issue is that the compiler does not (did not) deal well with redundant type constraints. Which eventually manifests itself in mismatching llvm types causing this assertion. The workaround is to remove the redundant constraints if possible. In this case we have: public protocol Model {
}
open class FindRequest<T: RecordTemplate, MD: RecordTemplate>: Request {
}
open class Request {
open func cacheKey() -> String {
return ""
}
}
open class CollectionResponse<V: RecordTemplate, MD: RecordTemplate> {
}
open class RecordTemplate {
}
// Another file:
func extractCollectionModel<ModelType : Model , MetadataType: Model>(_ response: CollectionResponse<ModelType, MetadataType>?) {
}
extension RecordTemplate : Model {
}
public protocol CachableRequest {
/**
Customized cacheKey to return alternative cache key if specified
*/
func ndlCacheKey() -> String
/**
This is implmented by the Request class.
*/
func cacheKey() -> String
}
extension FindRequest: CachableRequest {
}
// MARK: Implementation
extension CachableRequest {
/**
customized cacheKey to return alternative cache key if specified
*/
public func ndlCacheKey() -> String {
return cacheKey()
}
} The problem is that the three generic parameter constraints in the system "ModelType : Model , MetadataType: Model" and "RecordTemplate : Model" create a redundant set of constraints on RecordTemplate. func extractCollectionModel<ModelType : Model , MetadataType: Model>(_ response: CollectionResponse<ModelType, MetadataType>?) {
}
extension RecordTemplate : Model {
} Eliminating either one of those constraints will make this example pass. // ModelType and MetadataType are already constraint to be of protocol type Model because CollectionResponse's generic parameters are constraint to be RecordTemplate.
func extractCollectionModel<ModelType , MetadataTypel>(_ response: CollectionResponse<ModelType, MetadataType>?) {
}
extension RecordTemplate : Model {
} |
Comment by Robbert Brandsma (JIRA) This bug seems to still exist in Swift 4.2 / Xcode 10 |
obbut (JIRA User), it's likely the bug you're seeing has a different cause. Can you file it separately? |
Comment by Ramil Minibaev (JIRA) Seems to be resolved in Swift 5.5. Got this issue in my project in Swift 5.4, but not in Swift 5.5 |
Attachment: Download
Environment
Xcode 8.1, Swift 3
Additional Detail from JIRA
md5: 8d4ae1d8b2288094bcfe9de02fc2ebb1
Issue Description:
Compiling a project crashes the compiler with the following output:
I cannot seem to get the code smaller than this. Removing anything causes compilation to be successful. This also only fails on RELEASE builds.
The best way to reproduce is by downloading the attached project. But, the code is:
// In the main app
// In a framework called MyFramework
The text was updated successfully, but these errors were encountered: