Don't mark primitive types as @NotNull
This commit is contained in:
@@ -106,7 +106,10 @@ public abstract class AnnotationCodegen {
|
|||||||
private void generateNullabilityAnnotation(@Nullable JetType type, @NotNull Set<String> annotationDescriptorsAlreadyPresent) {
|
private void generateNullabilityAnnotation(@Nullable JetType type, @NotNull Set<String> annotationDescriptorsAlreadyPresent) {
|
||||||
if (type == null) return;
|
if (type == null) return;
|
||||||
|
|
||||||
Class<?> annotationClass = CodegenUtil.isNullableType(type) ? Nullable.class : NotNull.class;
|
boolean isNullableType = CodegenUtil.isNullableType(type);
|
||||||
|
if (!isNullableType && KotlinBuiltIns.getInstance().isPrimitiveType(type)) return;
|
||||||
|
|
||||||
|
Class<?> annotationClass = isNullableType ? Nullable.class : NotNull.class;
|
||||||
|
|
||||||
String descriptor = Type.getType(annotationClass).getDescriptor();
|
String descriptor = Type.getType(annotationClass).getDescriptor();
|
||||||
if (!annotationDescriptorsAlreadyPresent.contains(descriptor)) {
|
if (!annotationDescriptorsAlreadyPresent.contains(descriptor)) {
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
public interface Primitives extends jet.JetObject {
|
||||||
|
int $$int /* Real name is 'int' */(@jet.runtime.typeinfo.JetValueParameter(name = "x") int p);
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
java.lang.Boolean getNullableBool();
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
java.lang.Byte getNullableByte();
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
java.lang.Short getNullableShort();
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
java.lang.Character getNullableChar();
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
java.lang.Integer getNullableInt();
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
java.lang.Long getNullableLong();
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
java.lang.Float getNullableFloat();
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
java.lang.Double getNullableDouble();
|
||||||
|
|
||||||
|
boolean getBool();
|
||||||
|
|
||||||
|
byte getByte();
|
||||||
|
|
||||||
|
short getShort();
|
||||||
|
|
||||||
|
char getChar();
|
||||||
|
|
||||||
|
int getInt();
|
||||||
|
|
||||||
|
long getLong();
|
||||||
|
|
||||||
|
float getFloat();
|
||||||
|
|
||||||
|
double getDouble();
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
trait Primitives {
|
||||||
|
fun int(x: Int): Int
|
||||||
|
|
||||||
|
val nullableBool: Boolean?
|
||||||
|
val nullableByte: Byte?
|
||||||
|
val nullableShort: Short?
|
||||||
|
val nullableChar: Char?
|
||||||
|
val nullableInt: Int?
|
||||||
|
val nullableLong: Long?
|
||||||
|
val nullableFloat: Float?
|
||||||
|
val nullableDouble: Double?
|
||||||
|
|
||||||
|
val bool: Boolean
|
||||||
|
val byte: Byte
|
||||||
|
val short: Short
|
||||||
|
val char: Char
|
||||||
|
val int: Int
|
||||||
|
val long: Long
|
||||||
|
val float: Float
|
||||||
|
val double: Double
|
||||||
|
}
|
||||||
@@ -65,6 +65,10 @@ public class NullabilityAnnotationsTest extends KotlinAsJavaTestBase {
|
|||||||
doTest(getTestName(false));
|
doTest(getTestName(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testPrimitives() throws Exception {
|
||||||
|
doTest(getTestName(false));
|
||||||
|
}
|
||||||
|
|
||||||
private void doTest(@NotNull String fqName) {
|
private void doTest(@NotNull String fqName) {
|
||||||
PsiClass psiClass = finder.findClass(fqName, GlobalSearchScope.allScope(getProject()));
|
PsiClass psiClass = finder.findClass(fqName, GlobalSearchScope.allScope(getProject()));
|
||||||
if (!(psiClass instanceof KotlinLightClass)) {
|
if (!(psiClass instanceof KotlinLightClass)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user