import UIKit protocol DataSource: AnyObject { associatedtype CellType func createCellFor(index: Int, reusing cell: CellType?) -> CellType } class ContainerView where CellType: UIView { weak var dataSource: (any DataSource)? func fetchCells() { // Member 'createCellFor' cannot be used on value of type 'any DataSource'; consider using a generic constraint instead let cell = dataSource?.createCellFor(index: 0, reusing: reuseCell()) } func reuseCell() -> CellType { return CellType() } } class SomeClass: NSObject, DataSource { let thing = ContainerView() override init() { super.init() self.thing.dataSource = self } func createCellFor(index: Int, reusing cell: CellType?) -> UICollectionViewCell { return UICollectionViewCell(frame: .zero) } typealias CellType = UICollectionViewCell } /// is the solution something like: class ContainerView where CellType: UIView, DataSource: DataSource, DataSource.CellType == CellType { /* ... */ }