我正试图在项目中使用箭头分析来在编译时捕获异常。我关注这个页面,但当我进行Gradle构建时,我会得到一堆运行时异常
这是我的测试代码
fun main() {
val wrong = emptyList<Int>().get(2)
}
这是我的Gradle DSL构建脚本
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.7.10"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation("io.arrow-kt:arrow-core:1.1.2")
}
buildscript {
dependencies {
classpath("io.arrow-kt.analysis.kotlin:io.arrow-kt.analysis.kotlin.gradle.plugin:2.0")
}
}
apply(plugin = "io.arrow-kt.analysis.kotlin")
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
这是我在做Gradle构建时遇到的错误
java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.psi.KtExpression org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt.getReceiverExpression(org.jetbrains.kotlin.resolve.calls.model.ResolvedCall)'
at arrow.meta.plugins.analysis.phases.analysis.solver.ast.kotlin.KotlinResolvedCall.getReceiverExpression(KotlinResolvedCall.kt:37)
at arrow.meta.plugins.analysis.phases.analysis.solver.ResolvedCallUtilsKt.allArgumentExpressions(ResolvedCallUtils.kt:75)
at arrow.meta.plugins.analysis.phases.analysis.solver.ResolvedCallUtilsKt.arg(ResolvedCallUtils.kt:119)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt.controlFlowAnyFunction(Expressions.kt:438)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt.checkCallExpression(Expressions.kt:397)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt.fallThrough(Expressions.kt:260)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt.access$fallThrough(Expressions.kt:1)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt$checkExpressionConstraints$2.invoke(Expressions.kt:244)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.ExpressionsKt$checkExpressionConstraints$2.invoke(Expressions.kt:157)
at arrow.meta.continuations.ContSeq$flatMap$1.invokeSuspend(ContSeq.kt:60)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeq$map$1.invokeSuspend(ContSeq.kt:292)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeq$map$1.invokeSuspend(ContSeq.kt:292)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeq$map$1.invokeSuspend(ContSeq.kt:292)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeqBuilder.yieldAll(ContSeq.kt:274)
at arrow.meta.continuations.ContSeqSyntax$DefaultImpls.yieldAll(ContSeq.kt:165)
at arrow.meta.continuations.ContSeqBuilder.yieldAll(ContSeq.kt:203)
at arrow.meta.continuations.ContSeq$flatMap$1.invokeSuspend(ContSeq.kt:60)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeq$map$1.invokeSuspend(ContSeq.kt:292)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeq$map$1.invokeSuspend(ContSeq.kt:292)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeqBuilder.yieldAll(ContSeq.kt:274)
at arrow.meta.continuations.ContSeqSyntax$DefaultImpls.yieldAll(ContSeq.kt:165)
at arrow.meta.continuations.ContSeqBuilder.yieldAll(ContSeq.kt:203)
at arrow.meta.continuations.ContSeq$flatMap$1.invokeSuspend(ContSeq.kt:60)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeq$map$1.invokeSuspend(ContSeq.kt:292)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeq$map$1.invokeSuspend(ContSeq.kt:292)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeqBuilder.yieldAll(ContSeq.kt:274)
at arrow.meta.continuations.ContSeqSyntax$DefaultImpls.yieldAll(ContSeq.kt:165)
at arrow.meta.continuations.ContSeqBuilder.yieldAll(ContSeq.kt:203)
at arrow.meta.continuations.ContSeq$flatMap$1.invokeSuspend(ContSeq.kt:60)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeq$map$1.invokeSuspend(ContSeq.kt:292)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeq$map$1.invokeSuspend(ContSeq.kt:292)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeqBuilder.yieldAll(ContSeq.kt:274)
at arrow.meta.continuations.ContSeqSyntax$DefaultImpls.yieldAll(ContSeq.kt:165)
at arrow.meta.continuations.ContSeqBuilder.yieldAll(ContSeq.kt:203)
at arrow.meta.continuations.ContSeq$flatMap$1.invokeSuspend(ContSeq.kt:60)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeqBuilder.yieldAll(ContSeq.kt:274)
at arrow.meta.continuations.ContSeqSyntax$DefaultImpls.yieldAll(ContSeq.kt:165)
at arrow.meta.continuations.ContSeqBuilder.yieldAll(ContSeq.kt:203)
at arrow.meta.continuations.ContSeq$flatMap$1.invokeSuspend(ContSeq.kt:60)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at arrow.meta.continuations.ContSeqBuilder.hasNext(ContSeq.kt:233)
at arrow.meta.continuations.ContSeq.drain(ContSeq.kt:297)
at arrow.meta.plugins.analysis.phases.analysis.solver.check.EntryPointKt.checkDeclarationConstraints(EntryPoint.kt:69)
at arrow.meta.plugins.analysis.phases.PhasesKt$analysisPhases$4.invoke(Phases.kt:128)
at arrow.meta.plugins.analysis.phases.PhasesKt$analysisPhases$4.invoke(Phases.kt:121)
at arrow.meta.dsl.config.ConfigSyntax$storageComponent$1.check(ConfigSyntax.kt:72)
at arrow.meta.internal.registry.InternalRegistry$DelegatingContributor$registerModuleComponents$2.check(InternalRegistry.kt:651)
at org.jetbrains.kotlin.resolve.ModifiersChecker$ModifiersCheckingProcedure.runDeclarationCheckers(ModifiersChecker.java:285)
at org.jetbrains.kotlin.resolve.ModifiersChecker$ModifiersCheckingProcedure.checkModifierListCommon(ModifiersChecker.java:224)
at org.jetbrains.kotlin.resolve.ModifiersChecker$ModifiersCheckingProcedure.checkModifiersForDeclaration(ModifiersChecker.java:183)
at org.jetbrains.kotlin.resolve.DeclarationsChecker.process(DeclarationsChecker.kt:102)
at org.jetbrains.kotlin.resolve.BodyResolver.resolveBodies(BodyResolver.java:258)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations(LazyTopDownAnalyzer.kt:227)
at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations$default(LazyTopDownAnalyzer.kt:58)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:130)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:99)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:264)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:55)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:255)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.repeatAnalysisIfNeeded(KotlinToJVMBytecodeCompiler.kt:189)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.repeatAnalysisIfNeeded(KotlinToJVMBytecodeCompiler.kt:189)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:101)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:60)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:157)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:94)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:477)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:127)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:366)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:311)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:175)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:75)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:625)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1739)
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 java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
是否有任何特定的JVM版本或kotlin版本需要在项目中使用它
您能检查2.0.2版本吗?这个错误(或者至少是一个非常相似的错误(在那个版本中被修复了。