-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[java-analysis] Parameter nullability: prefer nullability known from …
…type over nullability known from parameter declaration Type nullability could be more precise if parameter is generic Fixes IDEA-364343 False-positive NPE at unboxing inside lambda with JSpecify annotations GitOrigin-RevId: 9a49f5687eccaa013e639cdf15950be911e100bc
- Loading branch information
1 parent
74904a8
commit ce18179
Showing
3 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
java/java-tests/testData/inspection/dataFlow/fixture/JSpecifyUnboxingInLambda.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import org.jspecify.annotations.NullMarked; | ||
import org.jspecify.annotations.Nullable; | ||
|
||
// IDEA-364343 | ||
@NullMarked | ||
class AnotherActivity { | ||
public interface ThrowingFunction<T1 extends @Nullable Object, T2 extends @Nullable Object> { | ||
T2 apply(T1 input) throws Throwable; | ||
} | ||
|
||
abstract static class Decoder<T extends @Nullable Object> { | ||
abstract <T2 extends @Nullable Object> Decoder<T2> then( | ||
ThrowingFunction<? super T, ? extends T2> dataTransform); | ||
} | ||
|
||
native Decoder<Boolean> foo(); | ||
|
||
Decoder<Boolean> doWork() { | ||
return foo().then(f -> !f); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters