ursus
07/22/2018, 3:24 PMWHEN_ENUM_CAN_BE_NULL_IN_JAVA
is so annoying, then my enum is in kotlinkarelpeeters
07/22/2018, 4:31 PMursus
07/22/2018, 4:54 PMwhen
over my enum, which is defined in kotlin, i get that warningkarelpeeters
07/22/2018, 4:58 PMenum class Test { A, B }
val test = Test.A
when(test) {
Test.A -> println("a")
Test.B -> println("b")
}
doesn't give me any warnings.ursus
07/22/2018, 5:01 PMursus
07/22/2018, 5:01 PM.subscribe {
when (it) {
ServiceCommand.START -> callServiceController.start()
ServiceCommand.STOP -> callServiceController.stop()
ServiceCommand.NO_OP -> Unit
}
}
ursus
07/22/2018, 5:01 PMkarelpeeters
07/22/2018, 5:02 PMit!!
?ursus
07/22/2018, 5:03 PMServiceCommand!
as typeursus
07/22/2018, 5:03 PMursus
07/22/2018, 5:04 PMfun <T : Any> Observable<T>.wrappedSubscribe(onNext: (T) -> Unit): Disposable {
return subscribe(onNext)
}
karelpeeters
07/22/2018, 5:05 PMursus
07/22/2018, 5:05 PMkarelpeeters
07/22/2018, 5:06 PMursus
07/22/2018, 5:06 PMkarelpeeters
07/22/2018, 5:07 PMWHEN_ENUM_CAN_BE_NULL_IN JAVA
? And don't you want wrappedSubscribe
?ursus
07/22/2018, 5:10 PMursus
07/22/2018, 5:10 PMursus
07/22/2018, 5:10 PMursus
07/22/2018, 5:13 PMkarelpeeters
07/22/2018, 5:16 PM<ServiceCommand>
as the type parameter?ursus
07/22/2018, 5:17 PMursus
07/22/2018, 5:18 PMursus
07/22/2018, 5:19 PMkarelpeeters
07/22/2018, 5:20 PMkarelpeeters
07/22/2018, 5:20 PMit!!
should be fine simple smileursus
07/22/2018, 5:20 PMdiesieben07
07/22/2018, 5:21 PMkarelpeeters
07/22/2018, 5:21 PMT
can be nullable depending on the callsite, T: Any
is nonnull and T: Any?
is certainly nullable.karelpeeters
07/22/2018, 5:22 PMT!
as the generic argument.diesieben07
07/22/2018, 5:22 PMObservable
is a java class, then even a Obserable<T : Any>
(pseudo-syntax) can take nulls, because it is java code.ursus
07/22/2018, 5:23 PMdiesieben07
07/22/2018, 5:23 PMursus
07/22/2018, 5:24 PMkarelpeeters
07/22/2018, 5:24 PMwrappedSubscribe
receives a parameter of type T
, which is inferred to be ServiceCommand!
but it should have bound T: Any
.karelpeeters
07/22/2018, 5:25 PMServiceCommand! : Any
shouldn't work.diesieben07
07/22/2018, 5:25 PMdiesieben07
07/22/2018, 5:25 PMdiesieben07
07/22/2018, 5:26 PMServiceCommand! : Any
needs to work, otherwise platform types fall apart.karelpeeters
07/22/2018, 5:26 PMit: ServiceCommand!
, and it
has type T
.ursus
07/22/2018, 5:26 PM