Bradleycorn
09/19/2025, 7:12 PMclass MyKotlinClass {
   suspend fun doWork() {
      // fetch data from an api using ktor
   }
}
My ios project is using swift 6.2. I have setup the project in xcode with default actor isolation to use MainActor by default.
My understanding is that swift 6.2 also applies nonisolated(nonsending) as the default on async functions, so if you have some code like this, the async function will be called on the MainActor:
class SwiftClass {
   let repoClass: SomeSwiftRepository
   func doSwiftThings() async {
      try await repoClass.someAyncFunction()
   }
}
And indeed this works. I don't see any errors.
However, if I try to use the Kotlin object instead, I get concurrency errors:
class SwiftClass {
   let repoClass: MyKotlinClass
   func doSwiftThings() async {
      try await repoClass.doWork()
   }
}
But here's the part I really don't understand. It tells me that
> @concurrent instance method 'doWork() risks causing data races. 
I understand why a @concurrent method here would have a risk of data races. What I don't understand is why swift thinks it's @concurrent?  It's swift 6.2, shouldn't it use the default nonisolated(nonsending) ? I even enabled the NonisolatedNonsendingByDefault compiler flag to be extra sure.  Nowhere in any of the generated headers or code from the kotlin library do I see that doWork is marked as @concurrent. So where is that coming from? And even more confusing, if I remove the NonisolatedNonsendingByDefault compiler flag, then the error changes and tells me that:
>  doWork is a "nonisolated instance method".
This confuses me. Like I said, I understand why a @concurrent or nonisolated method call would risk data races. I don't understand why the kotlin method call is getting flagged as such.  Concurrency in swift is hard all on its own. Concurrency with Kotlin code running in swift is x10000, and it doesn't help that there's very little documentation (that I can find) about how concurrency interop between kotlin and swift does/doesn't work. Thankfully there is some information in the skie suspend functions documentation about how things work.Tadeas Kriz
09/20/2025, 12:36 AMNonisolatedNonsendingByDefault flag to the SKIE Swift compilation