MR3Y
Apr 16, 2022

Great article! it is definitely one of the best resources to start getting your hands dirty with ksp.

just a small modification, in this code snippet:

`file += if (resolvedType?.nullability == Nullability.NULLABLE) "?" else ""

val genericArguments: List<KSTypeArgument> = typeArgument.type?.element?.typeArguments ?: emptyList()

visitTypeArguments(genericArguments)`

we should check for nullability after visiting the type arguments not before that, so, if you have a type like that:

`Map<String, List<*>>?` with the above code it would be generated as follows:

`Map?<String, List<*>>` which is definitely not correct , and the generated code wouldn't even compile

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

MR3Y
MR3Y

Written by MR3Y

Eager to learn more and more! I hate boilerplate. I blog to share some tips & tricks and to talk about my humble opinion.

Responses (1)

Write a response