Description
Previous ID | SR-12354 |
Radar | rdar://problem/60383688 |
Original Reporter | tannernelson (JIRA User) |
Type | Bug |
Environment
Xcode Version 11.4 beta 3 (11N132i)
macOS 10.15
Additional Detail from JIRA
Votes | 6 |
Component/s | Compiler |
Labels | Bug, 5.2Regression, AssociatedTypeInference |
Assignee | None |
Priority | Medium |
md5: bdc582c5c5b3ebba399c6dbb3afaae12
Issue Description:
https://github.com/vapor/api-template @ af8148b447a16f22db819737ad97da9beef634f5
https://github.com/nodes-vapor/jwt-keychain @ 55dd5703e90c8c673ac62051aca312541a8c40f2
These two projects show examples of a regression in the Swift 5.2 compiler causing many Vapor 3 projects to not compile. To reproduce the bug, compile those commit hashes with Swift 5.2.
The regression is based around this code:
public protocol Model {
associatedtype Database
}
Each database package introduces types like:
public protocol MySQLModel: Model
where Self.Database == MySQLDatabase
{ }
In 5.1 and earlier this allowed for declarations of models to look like:
final class Todo: SQLiteModel {
...
}
However, with 5.2, the `Database` typealias must be provided even though it is constrained to a specific type by the protocol being conformed to.
final class Todo: SQLiteModel {
// Swift 5.2 requires this even though SQLiteModel constrains Database
// to this exact type.
typealias Database = SQLiteDatabase
...
}