Description
Previous ID | SR-11611 |
Radar | rdar://problem/56262165 |
Original Reporter | mlwoollard (JIRA User) |
Type | Bug |
Attachment: Download
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, 5.1Regression |
Assignee | @slavapestov |
Priority | Medium |
md5: 0246f94be1e0ded3b759c985ed36a797
Issue Description:
I have some code that is basically:
// Module 1
public protocol P {
associatedtype A
associatedtype B
init()
func run(a: A) -> B
}
public protocol C {}
open class C1<A, B: C>: P {
required init() {}
open func run(a: A) { return // some instance of B }
}
// Module 2
public protocol T {}
// Module 3
class CC: C {}
class C2: C1<T, CC> {
override func run(a: A) -> B {...}
}
// Then have extension to Set
extension Set where Element: C2 {
func getC2() -> Element {
return Element.init()
}
}
With Xcode 10.3 / Swift 5.0.1 this works as expected and getC2() return instance of C2. However with Xcode 11.1 / Swift 5.1 getC2() is returning instance of C1<T, CC> and so when `run(a: A)` is called the base class method is called and not the C2 overridden method.
For the real case, `print("(instanceOfInstantiatedClass)")` immediately after the code instantiates an instance as indicated above, same code compiled in the two environments:
Swift 5.0.1 outputs the subclass as expected
`TicketlessCore.ProductCellCoordinator`
Swift 5.1 outputs the base class with generic parameters provided by subclass (and breaks things as the subclass overridden method does not get called).
`UTMMVC.CellCoordinator<UTProducts.TicketProduct, TicketlessCore.ProductCell>`
This is part of large complex project and I've not yet been able to reproduce in simpler form suitable for adding here (but will continue to try to do so). If there's anything else that can help let me know and any suggestions of a work around?