diff --git a/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullIntArray.java b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullIntArray.java new file mode 100644 index 00000000000..7635322b66a --- /dev/null +++ b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullIntArray.java @@ -0,0 +1,8 @@ +package test; + +import org.jetbrains.annotations.NotNull; + +public class NotNullIntArray { + @NotNull + public int[] hi() { return null; } +} diff --git a/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullIntArray.kt b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullIntArray.kt new file mode 100644 index 00000000000..396a2f5a410 --- /dev/null +++ b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullIntArray.kt @@ -0,0 +1,5 @@ +package test + +public open class NotNullIntArray() : java.lang.Object() { + public open fun hi(): IntArray = throw Exception() +} diff --git a/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullIntArray.txt b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullIntArray.txt new file mode 100644 index 00000000000..f45b01ca009 --- /dev/null +++ b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullIntArray.txt @@ -0,0 +1,6 @@ +package test + +public open class NotNullIntArray : java.lang.Object { + public constructor NotNullIntArray() + public open fun hi(): jet.IntArray +} diff --git a/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullObjectArray.java b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullObjectArray.java new file mode 100644 index 00000000000..bf296de6e58 --- /dev/null +++ b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullObjectArray.java @@ -0,0 +1,8 @@ +package test; + +import org.jetbrains.annotations.NotNull; + +public class NotNullObjectArray { + @NotNull + public Object[] hi() { return null; } +} diff --git a/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullObjectArray.kt b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullObjectArray.kt new file mode 100644 index 00000000000..85ffaefdcc8 --- /dev/null +++ b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullObjectArray.kt @@ -0,0 +1,5 @@ +package test + +public open class NotNullObjectArray() : java.lang.Object() { + public open fun hi(): Array = throw Exception() +} diff --git a/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullObjectArray.txt b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullObjectArray.txt new file mode 100644 index 00000000000..e39922cf919 --- /dev/null +++ b/compiler/testData/loadJava/compiledJavaCompareWithKotlin/notNull/NotNullObjectArray.txt @@ -0,0 +1,6 @@ +package test + +public open class NotNullObjectArray : java.lang.Object { + public constructor NotNullObjectArray() + public open fun hi(): jet.Array +} diff --git a/compiler/tests/org/jetbrains/jet/lang/resolve/lazy/LazyResolveRecursiveComparingTestGenerated.java b/compiler/tests/org/jetbrains/jet/lang/resolve/lazy/LazyResolveRecursiveComparingTestGenerated.java index 08c564dc585..5639187eac4 100644 --- a/compiler/tests/org/jetbrains/jet/lang/resolve/lazy/LazyResolveRecursiveComparingTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/lang/resolve/lazy/LazyResolveRecursiveComparingTestGenerated.java @@ -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"); diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/types/LazyJavaTypeResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/types/LazyJavaTypeResolver.kt index 8cd58538178..5f5b421602b 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/types/LazyJavaTypeResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/types/LazyJavaTypeResolver.kt @@ -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(