e72ddbcbfe
To do so, inside the root cause of inapplicable candidate errors, we will record expected/actual type of receiver, if any. That will help identifying inapplicable calls on nullable receiver.
25 lines
505 B
Kotlin
Vendored
25 lines
505 B
Kotlin
Vendored
// FILE: Foo.java
|
|
public class Foo {
|
|
public String bar;
|
|
|
|
private Foo(String bar) {
|
|
this.bar = bar;
|
|
}
|
|
|
|
public static Foo create(String bar) {
|
|
return new Foo(bar);
|
|
}
|
|
}
|
|
|
|
// FILE: Test.kt
|
|
fun test() {
|
|
val foo = Foo.create(null)
|
|
foo?.bar.let {
|
|
// Error, foo?.bar is nullable
|
|
it.<!UNSAFE_CALL!>length<!>
|
|
// Foo is nullable but flexible, so call is considered safe here
|
|
foo.bar.length
|
|
// Correct
|
|
foo?.bar?.length
|
|
}
|
|
} |