willowtreeapps / assertk

assertions for kotlin inspired by assertj
MIT License
760 stars 85 forks source link

New assertion overload: inline reified `isInstanceOf` / `isNotInstanceOf` #454

Closed JakeWharton closed 1 year ago

JakeWharton commented 1 year ago

I'm really not one for code golf or anything, but I was surprised at its omission. My justification is that isInstanceOf(KClass<T>) provides the base functionality, and by the nature of reified requiring inline an inline fun <reified T : Any> Assert<Any>.isInstanceOf(): Assert<T> helper provides language feature support on top.

It also potentially allows inference to be used so as to not require explicitly specifying the type at the function call at all?

JakeWharton commented 1 year ago

(Also happy to contribute this and the others. Doing a big conversion and want to write everything down as I see it lest I forgot something that stands out)

evant commented 1 year ago

The reason for it's omission was the ide experience really wasn't great in that it would really push you to omit passing anything into the generics which made it's common usage confusing. I do not feel that strongly about it though.

JakeWharton commented 1 year ago

Seems okay? Any more details on what wasn't a good experience?

https://user-images.githubusercontent.com/66577/234742513-9722b639-2551-4900-9e09-0c58d8fbc876.mov

evant commented 1 year ago

It's been a long while since I looked, it's possible they improved/fixed it. I remember it not giving you the braces before.

JakeWharton commented 1 year ago

I'll move forward with the implementation and see if anything else comes about.