hmlongco / Factory

A new approach to Container-Based Dependency Injection for Swift and SwiftUI.
MIT License
1.83k stars 115 forks source link

typealias with 2 protocols leads to EXC_BAD_ACCESS #197

Closed dsuresh-ap closed 3 months ago

dsuresh-ap commented 6 months ago

I have the following code:

protocol DataSource<Model>
protocol DataSyncSource<Model>
typealias CloudDataSyncSource<Modal> = DataSource<Modal> & DataSyncSource<Modal>

My injection:

var conversationCloudDataSyncSource: Factory<any CloudDataSyncSource<ConversationModal>> {
        self { ConversationFirebaseDataSource() }.cached
    }

@Injected(\DataContainer.conversationCloudDataSyncSource) private var cloudMessageDataSyncSource

However I get EXC_BAD_ACCESS (code=2 on access of the DataSyncSource methods if I set the typealias (CloudDataSyncSource) as the registration type. If I specify the type as DataSyncSource then access is fine. Any ideas?

hmlongco commented 3 months ago

Was looking to see if this was an issue in Swift 6/Xcode 16, but code doesn't compile. Need working code subset that compiles, please.