Skip to content
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

Swift compiler type-check #282

Open
mina-kleid-mobile opened this issue Mar 20, 2023 · 0 comments
Open

Swift compiler type-check #282

mina-kleid-mobile opened this issue Mar 20, 2023 · 0 comments

Comments

@mina-kleid-mobile
Copy link

In our project we enabled the swift compiler diagnostics -Xfrontend -debug-time-expression-type-checking and we found there were a lot of time spent type-checking code that uses combineLatest and/or with(latestFrom:).

After digging deep in the issue we fount the root cause is coming from having these overloaded functions with generics from the library itself

Is this a know issue? and do you have a solution for this?

Example that triggers the warning when limit is 100ms. It shows us 170ms is spent on type-checking this expression

 signal
      .combineLatest(with: signal2)
      .map { $0 + $1 }
      .combineLatest(with: signal3)
      .map { $0 + $1 }

The overloading of functions

To give a better look, here is a snippet for the 3 overloaded functions extracted from SignalProtocol + Combining. The way they are written, they checking on error types for Element & O.

protocol SignalProtocol {
   associatedType Element
    
   public func combineLatest<O: SignalProtocol>(with other: O) -> Signal<(Element, O.Element), Error> where O.Error == Error

   public func combineLatest<O: SignalProtocol>(with other: O) -> Signal<(Element, O.Element), Error> where O.Error == Never
}

extension SignalProtocol where Error == Never {
   public func combineLatest<O: SignalProtocol>(with other: O) -> Signal<(Element, O.Element), O.Error>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant