I can accomplish this with star types, but I'd rather have the type safety (and also the intellij he...
s
I can accomplish this with star types, but I'd rather have the type safety (and also the intellij help from knowing the type)
a
Why is
*
less safe in your example?
s
I can't really think of any reason it's less safe other than if the library I'm calling decides to change their signature, then my code will still compile (when it probably shouldn't)
a
*
just says I don't care what Generic Type the class has, I won't use it anyway, so if you actually not gonna use it, its safe to use
*
IMO
s
yeah, sounds good. I'll go with the
*
, but that means there is no way to grab the type of
this
and use it as the generic type? that kinda sucks. 😕
k
Well do you need to use it or not?
a
you can't use generic functions of
this
, yes
k
Can't you just add another generic type parameter that's not
reified
and isn't used?
a
@karelpeeters if you specify one parameter, you have to specify all of them. its either none or all
k
Huh that's too bad.
s
yeah 😞
it's an interface to a library function, whether it's used in the future or not is not up to me.
a
Hi, is it valid to create an extension to the exception? something like this:
fun <T : Exception> T.expect(res: ResultValidator<A???>): ResultValidator<A???>
And then call like:
AccessDeniedException.expect(resultValidatorOfTypeBlah)
s
no, it's all a chain, so
expectException
is called on a chain of other methods.