https://kotlinlang.org logo
#announcements
Title
# announcements
c

czyzby

06/13/2017, 5:04 PM
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

ilya.gorbunov

06/13/2017, 5:38 PM
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

czyzby

06/13/2017, 5:41 PM
@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

ilya.gorbunov

06/13/2017, 5:43 PM
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

czyzby

06/13/2017, 5:49 PM
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

ilya.gorbunov

06/13/2017, 6:10 PM
Please check what is the API version in Kotlin facet (Project Structure -> Modules -> Your module -> Kotlin)
c

czyzby

06/13/2017, 6:16 PM
@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

ilya.gorbunov

06/13/2017, 6:20 PM
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

czyzby

06/13/2017, 6:22 PM
Referenced by some of my dependencies, but not explicitly.
I include 1.1 as test dependency.
i

ilya.gorbunov

06/13/2017, 6:23 PM
And does it help?
c

czyzby

06/13/2017, 6:24 PM
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

ilya.gorbunov

06/13/2017, 6:40 PM
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

czyzby

06/13/2017, 6:53 PM
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.