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

Ambiguous use of distinctUntilChanged() on Observables with optional values #1611

Closed
7 tasks
andreasmpet opened this issue Apr 6, 2018 · 5 comments
Closed
7 tasks

Comments

@andreasmpet
Copy link

Short description of the issue:

Calling the distinctUntilChanged() method on any observable sequence with an optional value will cause a compiler error complaining about ambiguous methods.

Expected outcome:

That the code compiles.

What actually happens:

Code does not compile, and yields error:
Ambiguous use of 'distinctUntilChanged()'

Self contained code example that reproduces the issue:

       let stringObservable: Observable<String?> = Observable<String?>.from(optional: nil)
        stringObservable.distinctUntilChanged()

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

RxSwift 4.1.2

Platform/Environment

  • [ x] iOS
  • macOS
  • tvOS
  • watchOS
  • playgrounds

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

  • [ x] easy, 100% repro
  • sometimes, 10%-100%
  • hard, 2% - 10%
  • extremely hard, %0 - 2%

Xcode version:

Xcode 9.3 release version
@andreasmpet
Copy link
Author

andreasmpet commented Apr 6, 2018

Current workaround is to use:
.distinctUntilChanged({ $0 == $1 })

Proposed fix in RxSwift:
Conditional compilation for older swift versions than 4.1 for distinctUntilChanged() definition in Driver+Optional.swift and Observable+Optional.swift

@kzaher
Copy link
Member

kzaher commented Apr 6, 2018

@Nailer we don't have Driver+Optional.swift and Observable+Optional.swift files here.

@vzsg
Copy link

vzsg commented Apr 6, 2018

Those seem to be part of RxOptional, not RxSwift after all. And it was fixed, but not tagged.

@andreasmpet
Copy link
Author

My mistake! I didn't check this before submitting.

@andreasmpet
Copy link
Author

Closing the issue since it's fixed in RxOptional

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

3 participants