Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlin 1.8 Modifiers [PRIVATE] are not allowed on Kotlin parameters. Allowed modifiers: [VARARG, NOINLINE, CROSSINLINE] #779

Open
akingyin1987 opened this issue Feb 10, 2023 · 5 comments

Comments

@akingyin1987
Copy link

version:4.9.2
Caused by: java.lang.IllegalArgumentException: Modifiers [PRIVATE] are not allowed on Kotlin parameters. Allowed modifiers: [VARARG, NOINLINE, CROSSINLINE]
at com.squareup.kotlinpoet.ParameterSpec.(ParameterSpec.kt:41)
at com.squareup.kotlinpoet.ParameterSpec.(ParameterSpec.kt:29)
at com.squareup.kotlinpoet.ParameterSpec$Builder.build(ParameterSpec.kt:157)
at com.squareup.kotlinpoet.FunSpec$Builder.addParameter(FunSpec.kt:465)
at permissions.dispatcher.processor.impl.kotlin.KotlinBaseProcessorUnit.createPermissionRequestClass(KotlinBaseProcessorUnit.kt:452)
at permissions.dispatcher.processor.impl.kotlin.KotlinBaseProcessorUnit.createPermissionRequestClasses(KotlinBaseProcessorUnit.kt:415)
at permissions.dispatcher.processor.impl.kotlin.KotlinBaseProcessorUnit.createFile(KotlinBaseProcessorUnit.kt:43)
at permissions.dispatcher.processor.impl.kotlin.KotlinBaseProcessorUnit.createFile(KotlinBaseProcessorUnit.kt:17)
at permissions.dispatcher.processor.PermissionsProcessor.processKotlin(PermissionsProcessor.kt:68)
at permissions.dispatcher.processor.PermissionsProcessor.process(PermissionsProcessor.kt:58)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt:90)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:197)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:980)
... 44 more

@akingyin1987
Copy link
Author

if google dagger2 version is 2.4.5

@kassim
Copy link

kassim commented Feb 23, 2023

I'm receiving this error as well

seems to be the same issue as #775

@minwonki
Copy link

minwonki commented Feb 28, 2023

I too have the same problem.
kotlin version : 1.8.10
permissionsdispatcher version : 4.9.2

Caused by: java.lang.IllegalArgumentException: Modifiers [PRIVATE] are not allowed on Kotlin parameters. Allowed modifiers: [VARARG, NOINLINE, CROSSINLINE]
at com.squareup.kotlinpoet.ParameterSpec.(ParameterSpec.kt:41)
at com.squareup.kotlinpoet.ParameterSpec.(ParameterSpec.kt:29)
at com.squareup.kotlinpoet.ParameterSpec$Builder.build(ParameterSpec.kt:157)
at com.squareup.kotlinpoet.FunSpec$Builder.addParameter(FunSpec.kt:465)
at permissions.dispatcher.processor.impl.kotlin.KotlinBaseProcessorUnit.createPermissionRequestClass(KotlinBaseProcessorUnit.kt:452)
at permissions.dispatcher.processor.impl.kotlin.KotlinBaseProcessorUnit.createPermissionRequestClasses(KotlinBaseProcessorUnit.kt:415)
at permissions.dispatcher.processor.impl.kotlin.KotlinBaseProcessorUnit.createFile(KotlinBaseProcessorUnit.kt:43)
at permissions.dispatcher.processor.impl.kotlin.KotlinBaseProcessorUnit.createFile(KotlinBaseProcessorUnit.kt:17)
at permissions.dispatcher.processor.PermissionsProcessor.processKotlin(PermissionsProcessor.kt:68)
at permissions.dispatcher.processor.PermissionsProcessor.process(PermissionsProcessor.kt:58)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt:90)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:197)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:985)
... 44 more

@kassim
Copy link

kassim commented Jun 13, 2023

I believe I used this workaround
#775 (comment)
(use com.github.permissions-dispatcher:permissionsdispatcher-ktx instead of the normal annotation version)

shaomaicheng pushed a commit to shaomaicheng/PermissionsDispatcher that referenced this issue Nov 10, 2023
Reason for the change:

Based on the issue: permissions-dispatcher#779

Bug reason:

When upgrading Kotlin or base library versions, some libraries that use KotlinPoet may also be upgraded to version 1.11 or higher.

KotlinPoet 1.11.0 has the following release note:

• Fix: Enforce only allowed parameter modifiers in ParameterSpec (i.e. crossinline, vararg, and noinline).

For more details, please refer to: https://github.com/square/kotlinpoet/releases

When generating the PermissionRequest class for methods annotated with @NeedsPermission, the private constructor will cause an error.

Reproduction steps:

Upgrade KotlinPoet to 1.11.0
Add a new parameter "callback" to the MainActivity#showCamera method in the sample
Modification:

Do not pass the KModifier.*PRIVATE parameter
@shaomaicheng
Copy link

I find reason for this issus,and i create a pr for this: #782

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants