Properly handle @NotNull for arrays
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class NotNullIntArray {
|
||||
@NotNull
|
||||
public int[] hi() { return null; }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
public open class NotNullIntArray() : java.lang.Object() {
|
||||
public open fun hi(): IntArray = throw Exception()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
public open class NotNullIntArray : java.lang.Object {
|
||||
public constructor NotNullIntArray()
|
||||
public open fun hi(): jet.IntArray
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class NotNullObjectArray {
|
||||
@NotNull
|
||||
public Object[] hi() { return null; }
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
public open class NotNullObjectArray() : java.lang.Object() {
|
||||
public open fun hi(): Array<Any> = throw Exception()
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
public open class NotNullObjectArray : java.lang.Object {
|
||||
public constructor NotNullObjectArray()
|
||||
public open fun hi(): jet.Array<jet.Any>
|
||||
}
|
||||
+10
@@ -2423,11 +2423,21 @@ public class LazyResolveRecursiveComparingTestGenerated extends AbstractLazyReso
|
||||
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NotNullIntArray.kt")
|
||||
public void testNotNullIntArray() throws Exception {
|
||||
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullIntArray.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NotNullMethod.kt")
|
||||
public void testNotNullMethod() throws Exception {
|
||||
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NotNullObjectArray.kt")
|
||||
public void testNotNullObjectArray() throws Exception {
|
||||
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullObjectArray.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NotNullParameter.kt")
|
||||
public void testNotNullParameter() throws Exception {
|
||||
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullParameter.kt");
|
||||
|
||||
+2
-2
@@ -69,14 +69,14 @@ class LazyJavaTypeResolver(
|
||||
val javaComponentType = arrayType.getComponentType()
|
||||
if (javaComponentType is JavaPrimitiveType) {
|
||||
val jetType = JavaToKotlinClassMap.getInstance().mapPrimitiveKotlinClass("[" + javaComponentType.getCanonicalText())
|
||||
if (jetType != null) return jetType
|
||||
if (jetType != null) return TypeUtils.makeNullableAsSpecified(jetType, !attr.isMarkedNotNull)
|
||||
}
|
||||
|
||||
val projectionKind = if (attr.howThisTypeIsUsed == MEMBER_SIGNATURE_CONTRAVARIANT && !isVararg) OUT_VARIANCE else INVARIANT
|
||||
|
||||
val howArgumentTypeIsUsed = isVararg.iif(MEMBER_SIGNATURE_CONTRAVARIANT, TYPE_ARGUMENT)
|
||||
val componentType = transformJavaType(javaComponentType, howArgumentTypeIsUsed.toAttributes())
|
||||
return TypeUtils.makeNullable(KotlinBuiltIns.getInstance().getArrayType(projectionKind, componentType))
|
||||
return TypeUtils.makeNullableAsSpecified(KotlinBuiltIns.getInstance().getArrayType(projectionKind, componentType), !attr.isMarkedNotNull)
|
||||
}
|
||||
|
||||
private class LazyStarProjection(
|
||||
|
||||
Reference in New Issue
Block a user