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

KSP2 version 2.0.0-1.0.23 crashes on Moshi codegen with NoSuchElementException: Collection contains no element matching the predicate. #1998

Closed
yogurtearl opened this issue Jul 12, 2024 · 0 comments · Fixed by #2013
Assignees
Labels
bug Something isn't working P1 major features or blocking bugs

Comments

@yogurtearl
Copy link

Kotlin 2.0.0 with K2
KSP 2.0.0-1.0.23 with KSP2
Moshi Code gen 1.15.1
Gradle 8.8

The kspKotlin task fails with a NoSuchElementException (see below)

Works as expected with KSP 2.0.0-1.0.22 with KSP2
Just upgrading from 2.0.0-1.0.22 to 2.0.0-1.0.23 with no other changes triggers this failure.

Try to code gen for something trivial:

@JsonClass(generateAdapter = true)
data class MyClass(
    val type: String
)

Fails with this error:

Caused by: java.util.NoSuchElementException: Collection contains no element matching the predicate.
        at com.google.devtools.ksp.impl.symbol.kotlin.UtilKt$annotations$3$1.invoke(util.kt:880)
        at com.google.devtools.ksp.impl.symbol.kotlin.UtilKt$annotations$3$1.invoke(util.kt:320)
        at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl$annotationApplication$2.invoke(KSAnnotationImpl.kt:58)
        at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl$annotationApplication$2.invoke(KSAnnotationImpl.kt:57)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl.getAnnotationApplication(KSAnnotationImpl.kt:57)
        at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl.access$getAnnotationApplication(KSAnnotationImpl.kt:41)
        at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl$arguments$2.invoke(KSAnnotationImpl.kt:73)
        at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl$arguments$2.invoke(KSAnnotationImpl.kt:72)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at com.google.devtools.ksp.impl.symbol.kotlin.KSAnnotationImpl.getArguments(KSAnnotationImpl.kt:72)
        at com.squareup.moshi.kotlin.codegen.ksp.ShadedUtilKt.createInvocationHandler(shadedUtil.kt:65)
        at com.squareup.moshi.kotlin.codegen.ksp.ShadedUtilKt.toAnnotation(shadedUtil.kt:59)
        at com.squareup.moshi.kotlin.codegen.ksp.ShadedUtilKt.access$toAnnotation(shadedUtil.kt:1)
        at com.squareup.moshi.kotlin.codegen.ksp.ShadedUtilKt$getAnnotationsByType$2.invoke(shadedUtil.kt:48)
        at com.squareup.moshi.kotlin.codegen.ksp.ShadedUtilKt$getAnnotationsByType$2.invoke(shadedUtil.kt:48)
        at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
        at kotlin.sequences.SequencesKt___SequencesKt.firstOrNull(_Sequences.kt:174)
        at com.squareup.moshi.kotlin.codegen.ksp.JsonClassSymbolProcessor.process(JsonClassSymbolProcessorProvider.kt:170)
        at com.google.devtools.ksp.impl.KotlinSymbolProcessing.execute(KotlinSymbolProcessing.kt:537)
        at com.google.devtools.ksp.impl.KSPLoader$Companion.loadAndRunKSP(KSPLoader.kt:36)
        at com.google.devtools.ksp.impl.KSPLoader.loadAndRunKSP(KSPLoader.kt)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at com.google.devtools.ksp.gradle.KspAAWorkerAction.execute(KspAATask.kt:523)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
        at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
        at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:209)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
        at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
        at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
        at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$0(DefaultWorkerExecutor.java:174)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:187)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:120)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:162)
        at org.gradle.internal.Factories$1.create(Factories.java:31)
        at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:264)
        at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:128)
        at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:133)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157)
        at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126)
        ... 2 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 major features or blocking bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants