Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

["Request"] Generated extensions fail to put parameter as nullable #147

Open
aballano opened this issue Jun 9, 2020 · 1 comment
Open
Labels
bug Something isn't working

Comments

@aballano
Copy link
Member

aballano commented Jun 9, 2020

See for example Semigroup's maybeCombine signature: fun A.maybeCombine(b: A?): A

None of the generated Semigroup instances generate the nullable parameter and therefore this function cannot be properly used.

@aballano aballano added the bug Something isn't working label Jun 9, 2020
@aballano aballano added this to the 0.11.0 milestone Jun 9, 2020
@aballano
Copy link
Member Author

aballano commented Jun 9, 2020

This issue seems to be caused by KotlinPoet itself, according to the last update (1.6.0):

Mirror API integrations, such as TypeElement.asClassName() and FunSpec.overriding(ExecutableElement), are being deprecated in this release. These KotlinPoet APIs are most often used in annotation processors. Since kapt runs annotation processors over stubs, which are Java files, a lot of the Kotlin-specific information gets lost in translation and cannot be accessed by KotlinPoet through the Mirror API integrations. Examples include:

Type nullability information is not accessible.

The correct solution is to switch to KotlinPoet-metadata or KotlinPoet-metadata-specs API, which fetches Kotlin-specific information from the @metadata annotation and produces correct KotlinPoet Specs. We may explore adding new metadata-based alternatives to the deprecated APIs in the future.

Although no specific information about how to handle this with the new libs is included.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant