Kroppeb
02/07/2020, 4:27 PMNothing at compile time?streetsofboston
02/07/2020, 4:37 PMNothing denotes the ‘empty-set’ which is a sub-set of all other possible sets. This means that Nothing is assignable to every possible type.
It is ugly, but you could force a function or a class-constructor to take an input-parameter of type T. If T is provided a Nothing, you code won’t compile.
fun <T> someFunction(dummy: T) ,
then calling someFunction<Nothing>(…) will never work, whatever you put in the spot of …, because dummy cannot be provided a value, since Nothing has no values in its set.Fleshgrinder
02/07/2020, 4:43 PMfun ƒ(x: Nothing?) { requireNonNull(x) } heheheKroppeb
02/07/2020, 4:46 PMstreetsofboston
02/07/2020, 4:46 PMnull to a Nothing value.Kroppeb
02/07/2020, 4:46 PMstreetsofboston
02/07/2020, 4:47 PMFleshgrinder
02/07/2020, 4:47 PMFleshgrinder
02/07/2020, 4:47 PMNothing?.Fleshgrinder
02/07/2020, 4:48 PMstreetsofboston
02/07/2020, 4:48 PMnull to a Nothing? , not to a Nothing.Fleshgrinder
02/07/2020, 4:48 PMFleshgrinder
02/07/2020, 4:48 PMstreetsofboston
02/07/2020, 4:49 PMNothing 🙂Fleshgrinder
02/07/2020, 4:49 PMstreetsofboston
02/07/2020, 4:49 PMFleshgrinder
02/07/2020, 4:49 PMstreetsofboston
02/07/2020, 4:49 PMFleshgrinder
02/07/2020, 4:49 PMKroppeb
02/07/2020, 4:51 PM. If I could just return the type I could at least mark the rest of the function as never executed. But-=` has to return UnitFleshgrinder
02/07/2020, 4:55 PMfun ƒ() = Unit