I have java code like compiles fine.
import org.jaitools.numeric.Range;
Range<Integer> r1 = Range.create(1, true, 4, true);
Converted to Scala like
val r1: org.jaitools.numeric.Range[Integer] = org.jaitools.numeric.Range.create(1, true, 4, true)
compilation fails as java seems to go for this method:
public static <T extends Number & Comparable> Range<T> create(T minValue, boolean minIncluded, T maxValue, boolean maxIncluded) {
return new Range<T>(minValue, minIncluded, maxValue, maxIncluded);
}
whereas the Scala compiler will choose to use
public static <T extends Number & Comparable> Range<T> create(T value, int... inf) {
return new Range<T>(value, inf);
}
i.e. the type arguments do not match.
Both are overloaded methods in the same class. How can I get the Scala compiler to choose the right method?
edit
val r1: org.jaitools.numeric.Range[Integer] = org.jaitools.numeric.Range.create(1, true, 4, true)
results in
overloaded method value create with alternatives:
[T <: Number with Comparable[_]](x$1: T, x$2: Int*)org.jaitools.numeric.Range[T] <and>
[T <: Number with Comparable[_]](x$1: T, x$2: Boolean, x$3: T, x$4: Boolean)org.jaitools.numeric.Range[T]
cannot be applied to (Int, Boolean, Int, Boolean)
val r1: org.jaitools.numeric.Range[Integer] = org.jaitools.numeric.Range.create(1, true, 4, true)
Maybe this is also a case of convert java to scala code - change of method signatures where the type system of java and Scala do not work well together?
int2Int?org.jaitools.numeric.Range.create(Integer.valueOf(1), true, Integer.valueOf(4), true)i.e. to use manual boxing. This works fine.