mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Added a check whether the nullable argument is the null constant to
avoid proposing the fix resulting in the unreachable code like
`f(null)` → `null?.let { f(it) }`
^KTIJ-20993 Fixed
(cherry-picked from commit 22819bcce03e5d53687cd832375486635ffc1647)
IJ-MR-20704
GitOrigin-RevId: 7932bc25ab2cfa4647c2b1dd046412ae419d92ad
52 lines
1.3 KiB
Plaintext
52 lines
1.3 KiB
Plaintext
// FILE: test.before.kt
|
|
// "Wrap with '?.let { ... }' call" "false"
|
|
// ACTION: Add 'toString()' call
|
|
// ACTION: Add names in comment to call arguments
|
|
// ACTION: Convert to run
|
|
// ACTION: Convert to with
|
|
// ACTION: Do not show hints for current method
|
|
package p;
|
|
|
|
fun test(x: Foo) {
|
|
x.foo(<caret>null);
|
|
}
|
|
|
|
// FILE: org/jspecify/nullness/NullMarked.java
|
|
package org.jspecify.nullness;
|
|
|
|
import static java.lang.annotation.ElementType.MODULE;
|
|
import static java.lang.annotation.ElementType.PACKAGE;
|
|
import static java.lang.annotation.ElementType.TYPE;
|
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
|
|
import java.lang.annotation.Documented;
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.Target;
|
|
|
|
@Target({TYPE, PACKAGE, MODULE})
|
|
@Retention(RUNTIME)
|
|
public @interface NullMarked {}
|
|
|
|
// FILE: org/jspecify/nullness/Nullable.java
|
|
package org.jspecify.nullness;
|
|
|
|
import static java.lang.annotation.ElementType.TYPE_USE;
|
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.Target;
|
|
|
|
@Target(TYPE_USE)
|
|
@Retention(RUNTIME)
|
|
public @interface Nullable {}
|
|
|
|
// FILE: p/Foo.java
|
|
package p;
|
|
|
|
import org.jspecify.nullness.NullMarked;
|
|
|
|
@NullMarked
|
|
public class Foo {
|
|
public void foo(String arg) {}
|
|
}
|