public class A<T extends Comparable> {}
import java.lang {Comparable}
import java.time {LocalDateTime}
A<T> bar<T>(A<T> t) given T satisfies Comparable<Object> {...}
void test() {
bar<LocalDateTime>(A<LocalDateTime>()); <============= Error [Type parameter T of declaration bar has argument LocalDateTime not assignable to upper bound Comparable<Object> of T]
}
My gut says my function definition should really be:
A<T> bar<T>(A<T> t) given T satisfies Comparable<out Object> {...}
But Ceylon doesn't support this. Is there a way to work around this? I don't have control over the Java lib I'm using; so A cannot be modified.
Thanks.
A<T> bar<T>(A<T> t) given T satisfies Comparable<Object> {...}
import java.lang {Comparable,Double}
import java.time {LocalDateTime, LocalDate}
import java.time.chrono {ChronoLocalDateTime}
A<T> bar<out T>(A<T> t) given T satisfies Comparable<T> {
return t;
}
void test() {
bar<Double>(A<Double>());
bar<LocalDateTime>(A<LocalDateTime>()); <=== Error [Type parameter T of declaration bar has argument LocalDateTime not assignable to upper bound Comparable<LocalDateTime> of T]
bar<ChronoLocalDateTime<LocalDate>>(A<ChronoLocalDateTime<LocalDate>>()); <=== Error [Type parameter T of declaration bar has argument ChronoLocalDateTime<LocalDate> not assignable to upper bound Comparable<ChronoLocalDateTime<LocalDate>> of T]
A<T> bar<T, U>(A<T> t) given T satisfies Comparable<U> & U given U satisfies Object => t;
results in the following error: Type parameter upper bounds are not yet supported in combination with other bounds
--
You received this message because you are subscribed to the Google Groups "ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-users...@googlegroups.com.
To post to this group, send email to ceylon...@googlegroups.com.
Visit this group at http://groups.google.com/group/ceylon-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-users/a900842e-5c0b-4c03-8404-da537d9e67ce%40googlegroups.com.
import java.lang {Comparable,Double}
import java.time {LocalDateTime, LocalDate}
import java.time.chrono {ChronoLocalDateTime}
A<T> bar<T>(A<T> t) given T satisfies Comparable<T> => t;
void test() {
bar<Double>(A<Double>());
bar<LocalDateTime>(A<LocalDateTime>());
bar<ChronoLocalDateTime<LocalDate>>(A<ChronoLocalDateTime<LocalDate>>());