mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-29 18:17:08 +07:00
To make error messages consistent #IDEA-374747 Fixed (cherry picked from commit 328c5b355fcf56a7d1c165aab32220d37bdfcbc1) IJ-MR-170004 GitOrigin-RevId: f00fb74ddbff84b18839c60648d664774d566966
39 lines
1.2 KiB
Java
39 lines
1.2 KiB
Java
import org.jspecify.annotations.NullMarked;
|
|
import org.jspecify.annotations.Nullable;
|
|
|
|
import java.lang.annotation.ElementType;
|
|
import java.util.function.Supplier;
|
|
|
|
@NullMarked
|
|
class Main {
|
|
|
|
public static void main(String[] args) {
|
|
Main.<<warning descr="Non-null type parameter 'T' cannot be instantiated with @Nullable type">@Nullable</warning> Object>fNonNullBound(() -> getNullableObject());
|
|
Main.<<warning descr="Non-null type parameter 'T' cannot be instantiated with @Nullable type">@Nullable</warning> Object>fNonNullBound(Main::getNullableObject);
|
|
|
|
}
|
|
|
|
static <T extends @Nullable Object> T fNullableBound(Supplier<T> supplier){
|
|
return supplier.get();
|
|
}
|
|
|
|
static <T> T fNonNullBound(Supplier<T> supplier){
|
|
return supplier.get();
|
|
}
|
|
|
|
static @Nullable Object getNullableObject() {
|
|
return null;
|
|
}
|
|
|
|
@NullableScope
|
|
static class NullableScopeClass {
|
|
void test() {
|
|
Main.<<warning descr="Non-null type parameter 'T' cannot be instantiated under @NullableScope">Object</warning>>fNonNullBound(Main::getNullableObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
@javax.annotation.meta.TypeQualifierDefault(ElementType.TYPE_USE)
|
|
@javax.annotation.Nullable
|
|
@java.lang.annotation.Target(ElementType.TYPE_USE)
|
|
@interface NullableScope {} |