So when I type UUID I am getting Java UUID from ja...
# multiplatform
v
So when I type UUID I am getting Java UUID from java.util. THIS IS IN commonMain THO 🚨 This does not turn red and does compile (as I am using desktop) but I think the IDE should exclude these. So one of three things is happening 1. Java util uuids work in android/desktop projects and the ide is intelligently determining that I can use them. This is the good ending. (I only have android and desktop as targets) 2. Multiplatform now supports java.util stuff. This is also the good ending but highly unlikely 3. This is an error in the template, this is the bad ending, in this case my dissapointment is high. I think #1 is most likely whats going on but I would like to confirm with people here.
1️⃣ 5
j
The common source set is the subset of all platform APIs that your project targets that are common between them all. Intermediate source sets can work in the same way. For example if you were to support a native target or JS, the common source set would no longer include JVM-specific APIs. But you could have a jvmCommon source set between jvm and android which would include those APIs.
☝️ 1
a
1️⃣ is the right sprit of things. Nitpick: It's not the IDE being clever, it's just the way Kotlin Multiplatform works. As @Jeff Lockhart says, commonMain will allow target-specific code IF the current targets all support that code.
v
I assume its at the ide level because if you actually add the unsupported code. It will still work on the supported targets and simply not build on unsupported targets. Is there something else that governs this behavior?
j
Ultimately, it's each individual platform target that's compiled. So it's the compiler of each of those targets that determines what's valid in common, as common is compiled for each of the targets, along with any other source set in the target's hierarchy. But the Kotlin IDE plugin does determine how to highlight code, yes.
v
ok that makes sense. Thanks for the explanation. Intellijent little plugin aint it
🙂 1
j
Yes it is! In general the Kotlin IDE plugin should show you accurately what your code will do at compile time. Occasionally there are edge cases where the IDE falsely identifies or fails to identify an error. KMP is complex!
plus1 1