Skip to content

Instantly share code, notes, and snippets.

@Morfly
Last active April 16, 2022 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Morfly/257b983680922c71eefb60ac963af74d to your computer and use it in GitHub Desktop.
Save Morfly/257b983680922c71eefb60ac963af74d to your computer and use it in GitHub Desktop.
override fun visitTypeArgument(typeArgument: KSTypeArgument, data: Unit) {
...
val resolvedType: KSType? = typeArgument.type?.resolve()
file += resolvedType?.declaration?.qualifiedName?.asString() ?: run {
logger.error("Invalid type argument", typeArgument)
return
}
// Generating nested generic parameters if any
val genericArguments: List<KSTypeArgument> = typeArgument.type?.element?.typeArguments ?: emptyList()
visitTypeArguments(genericArguments)
// Handling nullability
file += if (resolvedType?.nullability == Nullability.NULLABLE) "?" else ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment