Getting these sorts of erroneous type errors all o...
# intellij
d
Getting these sorts of erroneous type errors all over a mixed Java/Kotlin module. (required type: T provided: T šŸ™ƒ) Compiles fine however. Build #IU-251.26927.53 - ā—*Only occurs when K2 is enabled* ā—- known issue?
Found "IDEA-127767 Editor reports incompatible type error, but required type is the same as the found type", but it's very old. The symptom, at least, is back šŸ’€
a
Could you please let us know what are the signatures of the containing call and the
requestDTO.getDescription()
? Also please specify how many JDKs do you have and iff they are different on the call site and where the methods are declared. Thanks!
s
I’m seeing this as well. Here’s my Java code snippet from the screenshot:
Copy code
@Test
  public void resource() throws ExecutionException, InterruptedException {
    var expected = "sitrus";
    String actual = PokeApi.getDefault().getBerryAsync(10).get().getName();
    assertEquals(expected, actual);
  }
what are the signatures
getName()
here is from a
val name: String
on a Kotlin data class
Also please specify how many JDKs do you have
JDK is set to 21 via toolchain in Gradle.
and if they are different on the call site and where the methods are declared
The call site and the declaration are in the same module. It’s a Kotlin Multiplatform module. The declaration is in
commonMain/kotlin
, while the call site is in
jvmTest/java
.
Similar but different error if I call inline instead of using a `var`:
and another where it just can’t resolve `List<>.get`:
Using a variable there gives me ā€œunknown classā€
(all of this compiles fine, runs, and tests pass; just the IDE is wrong)
a
So you have java in common code? Sorry, seems I don't get it at all šŸ˜•
s
I have Kotlin in common code. Java in jvmTest code, because I want to make sure my library is usable from Java
Library is 100% Kotlin Multiplatform, there’s a little Java in the tests just in the jvmTest source set
a
Can you probably share a project without code (only dependencies/structure)?
s
I can share the code, it’s an open source library
pushing up the branch now
a
I see red code, will try to investigate. Thanks again!
gratitude thank you 1
reported as KT-78684