Problem with matching overloaded methods

Hi,

I’m trying to use the RxJava library from Silver and am getting the following compiler errors:

var stream: Observable<Int>
stream = Observable.just(1) // Silver error: No such static member
stream = Observable.just(Int(1)) // Silver error: No such static member
stream = Observable<Int>.just(1) // Silver error: Type mismatch, expected "rx.Observable<Long>"
stream = Observable<Int>.just(Int(1))

I can work around the problem with the last variant, which does not produce an error, but I’d prefer not to have to do this and, most importantly, I’d like to understand what’s going on and what the specific limitation is.

As background, I’m trying to create a Java class library from Swift source that can be linked with RxJava. My goal is to share a Functional Reactive Programming “core” that will be the basis for both an Android and iOS app. The library would conditionally compile with either RxJava or RxSwift, depending on the target. This is possible (I’m hoping) because of the similarity in the two Rx implementations in terms of classes and method signatures. Where there are minor differences, I figure I can provide a compatibility layer.

this compiles:

import rx

var stream: Observable<Int>
stream = Observable.just(1) // Silver error: No such static member
stream = Observable.just(Int(1)) // Silver error: No such static member
stream = Observable<Int>.just(1) // Silver error: Type mismatch, expected "rx.Observable<Long>"
stream = Observable<Int>.just(Int(1))

The problem you probably have is that there’s another Observable interface in java.util which is interfering with this one.

Thanks for the response, Carlo. I really appreciate it.

After a little trial and error, I found that I don’t get the compiler errors if I’m using the “Class Library” template, but get the first two if I use the “Console Application” template (see below). I can’t reproduce the third at all.

In any event, I can avoid the problem as you implied if I qualify the Observable reference with rx..

Thanks again.

hrmm that is curious. Check the project options, maybe java.util is a default uses.