You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/common-atomics.md
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -232,15 +232,21 @@ Though this is not a breaking change (the old Kotlin code using Java atomics wil
232
232
**How we can address this Kotlin-Java-Kotlin hierarchy problem:**
233
233
234
234
- From the front-end point of view, there can be a subtyping relation between `AtomicInt` and `AtomicInteger`,
235
-
then we can load java classes doing the full mapping like in the option 1, but mapping java `AtomicInteger` types to flexible types`AtomicInt`..`AtomicInteger`.
235
+
then we can load java classes doing the full mapping like in the option 1, but mapping java `AtomicInteger` types to _flexible types_`AtomicInt`..`AtomicInteger`.
236
236
- Forbid to use Kotlin atomics in open functions (via `@OptIn` or a compiler flag).
237
237
- We could introduce a compiler check: some Java function overrides a Kotlin function with Kotlin atomics in the signature.
238
238
239
-
**Can we actualize an expect function with `kotlin.AtomicInt` with an actual function with `j.u.c.a.AtomicInteger`?**
239
+
**Can we actualize an expect function with `k.c.a.AtomicInt` with an actual function with `j.u.c.a.AtomicInteger`?**
240
+
241
+
With the implementation, when Kotlin and Java atomics are incompatible types until codegen,
242
+
one cannot actualize an expect function having a `k.c.a.AtomicInt` in its signature with the function using `j.u.c.a.AtomicInteger`.
243
+
240
244
- When the actual function is written in Kotlin
241
-
-In this case the user should migrate to `kotlin.AtomicInt` in kotlin code first.
245
+
- the user should migrate to `k.c.a.AtomicInt` in kotlin code first.
242
246
- When the actual function is written in Java
243
-
- with the help of `@KotlinActual` annotation.
247
+
- Unfortunately, an expect Kotlin function using Kotlin atomics cannot be actualized with a Java implementation using `@KotlinActual` annotation.
248
+
Though if this scenario appears to be popular, it may be supported in the compiler by introduction of _flexible type mapping_ at FIR,
249
+
which was mentioned as one of the possible solutions to the Kotlin-Java-Kotlin hierarchy problem above.
0 commit comments