You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is somewhat related to #1398, with all the changes to the Observable method signatures to improve type inference. I was hoping something could be done to how subscribe(onNext: T => Unit): Subscription is defined, so the common Scala simplification of case class matching from example 1 to example 2 would still compile.
From my limited understanding of Scala type inference, the problem is that the compiler can't differentiate between subscribe(onNext: T => Unit): Subscription, subscribe(subscriber: Subscriber[T]): Subscription or subscribe(observer: Observer[T]): Subscription. Which leads to the dreaded "missing parameter type for expanded function. The argument types of an anonymous function must be fully known (SLS 8.5)" error.
If someone can point me in the right direction, I could create a pull request implementing the change and update examples, test cases etc as required. If this is simply not possible with Scala current type inference support, just close this issue and I'll have to live with the more verbose case class matching syntax.
The simplest solution to make your Example 2 work is to replace subscribe by foreach, which is just an alias for subscribe, but has no overloads of the same arity, so the problem that the compiler can't differentiate between the different overloads is gone.
Thanks, didn't think of using foreach, but that looks like a simple enough workaround.
Haven't used foreach much, since I don't really like that it hides the subscribe, making the code harder to read and understand IMHO, but I guess I'll have to make a choice.
This is somewhat related to #1398, with all the changes to the Observable method signatures to improve type inference. I was hoping something could be done to how
subscribe(onNext: T => Unit): Subscription
is defined, so the common Scala simplification of case class matching from example 1 to example 2 would still compile.Example 1
Example 2
From my limited understanding of Scala type inference, the problem is that the compiler can't differentiate between
subscribe(onNext: T => Unit): Subscription
,subscribe(subscriber: Subscriber[T]): Subscription
orsubscribe(observer: Observer[T]): Subscription
. Which leads to the dreaded "missing parameter type for expanded function. The argument types of an anonymous function must be fully known (SLS 8.5)" error.If someone can point me in the right direction, I could create a pull request implementing the change and update examples, test cases etc as required. If this is simply not possible with Scala current type inference support, just close this issue and I'll have to live with the more verbose case class matching syntax.
/cc @headinthebox, @zsxwing, @samuelgruetter for feedback.
The text was updated successfully, but these errors were encountered: