question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kotlin interop: reporting wrong type for inner classes appearing in Kotlin method types

See original GitHub issue

Compiler version

3.0.0-RC2

Minimized code

I’m working with a library that is written in kotlin, and running into a compilation error on 3.0.0-RC2 that doesn’t happen on 2.13.5. The decompiled .class file looks like:

public abstract class VerificationResult {
  public static final class Ok extends VerificationResult {...}
  public static final class Failed extends VerificationResult {...}
  ...
}

and then there is a method on another class like:

public void displayFailures(@NotNull List<Failed> failures)

I then get this compiler error when calling the method:

Output

[error] 16 |            verifier.displayFailures(List(failed).asJava)
[error]    |                                     ^^^^^^^^^^^^^^^^^^^
[error]    |Found:    java.util.List[au.com.dius.pact.provider.VerificationResult.Failed]
[error]    |Required: java.util.List[au.com.dius.pact.provider.VerificationResult$Failed]

Expectation

Should compile.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:35 (26 by maintainers)

github_iconTop GitHub Comments

4reactions
smartercommented, Apr 13, 2021
3reactions
smartercommented, Oct 1, 2021

Thanks for stepping up!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling Java from Kotlin
Kotlin is designed with Java interoperability in mind. ... When you call methods on variables of platform types, Kotlin does not issue nullability...
Read more >
Accessing static inner class defined in Java, through derived ...
In Kotlin, nested types and companion objects are not automatically inherited. ... Nested::class // Error: 'Nested' unresolved.
Read more >
Chapter 6. The Kotlin type system - Kotlin in Action
This chapter covers. Nullable types and syntax for dealing with null s; Primitive types and their correspondence to the Java types; Kotlin collections...
Read more >
Kotlin style guide | Android Developers
Like other programming style guides, the issues covered span not only aesthetic issues of formatting, but other types of conventions or coding standards...
Read more >
Using Kotlin Code from Java - InformIT
Here, you define an extension function that facilitates showing toast messages on Android and use @JvmName to provide a more descriptive name ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found