ibrahim koz
ibrahim koz

Reputation: 629

Kotlin NoSuchMethodError after installing a library that enables a plugin

I want to experience a library called arrow analysis

My build.gradle.kts file looks as follows:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm") version "1.7.10"
}

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    testImplementation(kotlin("test"))
    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.test {
    useJUnitPlatform()
}

tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "1.8"
}

after an attempt to build the project, I get the following error:

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)

I checked the source code, and everything seems to be in place. Did I something wrong as per the instructions to install this library which is denoted as follows:

buildscript {
  dependencies {
    classpath("io.arrow-kt.analysis.kotlin:io.arrow-kt.analysis.kotlin.gradle.plugin:2.0")
  }
}

apply(plugin = "io.arrow-kt.analysis.kotlin")

Upvotes: 1

Views: 1495

Answers (1)

Some random IT boy
Some random IT boy

Reputation: 8467

You need to apply the plugin inside the plugins block and in the same fashion you're applying the Kotlin JVM plugin.

They mention to use it like this on their official docs

plugins {
  kotlin("multiplatform") version "1.6.21"
  // other plugins
  id("io.arrow-kt.analysis.kotlin") version "2.0.2"
}

buildscript {
  repositories {
    mavenCentral()
  }
}

Upvotes: 1

Related Questions