I'm getting a `Unresolved reference: onEach` after...
# announcements
c
I'm getting a
Unresolved reference: onEach
after updating to
1.1.2-4
. The code compiles and runs fine on
1.1.2-3
. Is that a known issue?
i
czyzby: This can happen if you have API version setting set to 1.0. It constrains you from using new API introduced in 1.1. You can check its value in Kotlin facet of the module.
c
@ilya.gorbunov The thing is: the only setting I change is the Kotlin version, so if the Gradle or IntelliJ plugins do not default to 1.0 API, I just don't see how this is the issue. I'm also getting some errors during coroutines usage after the update.
i
By the way, if you use coroutines, you should really update to 1.1.2-5, as -4 version has a serious flaw when compiling suspend functions
c
Yeah, I think I've encountered that issue - I had to change
suspendCoroutine
to
suspendCancellableCoroutine
to even make it work. I'll try
1.1.2-5
, thanks.
@ilya.gorbunov I'm still getting that error for
onEach
. I've added this to my Gradle setup:
Copy code
compileTestKotlin {
  kotlinOptions {
    languageVersion = "1.1"
  }
}
...but it still complains about unresolved reference.
This must be an IntelliJ issue, as it compiles just fine through Gradle.
i
Please check what is the API version in Kotlin facet (Project Structure -> Modules -> Your module -> Kotlin)
c
@ilya.gorbunov Yes, that was the issue. What's the correct setup to achieve this? My main source modules default to 1.1 API level after Gradle import, but test modules are set as 1.0.
i
If you didn't set it explicitly in build.gradle it should be the same as the version of stdlib, namely 1.1. Is there any chance that you get kotlin-stdlib:1.0.x for tests?
c
Referenced by some of my dependencies, but not explicitly.
I include 1.1 as test dependency.
i
And does it help?
c
I mean, my Gradle script already includes the 1.1 as dependency.
And I'm still getting this issue.
Copy code
testCompile("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion") {
      force = true
    }
kotlinVersion
is
1.1.2-5
. Test modules are still imported with 1.0 kotlin version.
@ilya.gorbunov I had to remove all dependencies that used Kotlin 1.0 and reimport the project (Gradle refresh was not enough).
i
This may be fragile, and the problem can happen again when you add them back. If you get correct compilation and incorrect diagnostics in IDE related to gradle import please report it as an issue, with the build.gradle attached.
c
This might have been a weird cache issue, I'm unable to reproduce it after complete removal of the IntelliJ meta-data folder from the project.
I'll create an issue if I ever encounter the problem again. Thanks.