KT-56840 [SLC] Don't mark primitive-backed types with @NotNull
This commit is contained in:
committed by
Space Team
parent
bcb517d66b
commit
d81170fbcc
+1
-1
@@ -188,7 +188,7 @@ internal class SymbolLightFieldForProperty private constructor(
|
||||
// NB: not as?, since _initializerValue already checks that
|
||||
(propertySymbol as KtKotlinPropertySymbol).isConst &&
|
||||
// javac rejects all non-primitive and non String constants
|
||||
(propertySymbol.returnType.isPrimitive || propertySymbol.returnType.isString)
|
||||
(propertySymbol.returnType.isPrimitiveBacked || propertySymbol.returnType.isString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-13
@@ -126,28 +126,18 @@ internal fun KtAnalysisSession.getTypeNullability(ktType: KtType): NullabilityTy
|
||||
|
||||
if (ktType.isUnit) return NullabilityType.NotNull
|
||||
|
||||
if (ktType.isPrimitiveBacked) return NullabilityType.Unknown
|
||||
|
||||
if (ktType is KtTypeParameterType) {
|
||||
if (ktType.isMarkedNullable) return NullabilityType.Nullable
|
||||
val subtypeOfNullableSuperType = ktType.symbol.upperBounds.all { upperBound -> upperBound.canBeNull }
|
||||
return if (!subtypeOfNullableSuperType) NullabilityType.NotNull else NullabilityType.Unknown
|
||||
}
|
||||
if (ktType !is KtClassType) return NullabilityType.NotNull
|
||||
|
||||
if (!ktType.isPrimitive) {
|
||||
return ktType.nullabilityType
|
||||
}
|
||||
|
||||
if (ktType !is KtNonErrorClassType) return NullabilityType.NotNull
|
||||
if (ktType.ownTypeArguments.any { it.type is KtClassErrorType }) return NullabilityType.NotNull
|
||||
if (ktType.classId.shortClassName.asString() == SpecialNames.ANONYMOUS_STRING) return NullabilityType.NotNull
|
||||
|
||||
val canonicalSignature = ktType.mapTypeToJvmType().descriptor
|
||||
|
||||
if (canonicalSignature == "[L<error>;") return NullabilityType.NotNull
|
||||
|
||||
val isNotPrimitiveType = canonicalSignature.startsWith("L") || canonicalSignature.startsWith("[")
|
||||
|
||||
return if (isNotPrimitiveType) NullabilityType.NotNull else NullabilityType.Unknown
|
||||
return ktType.nullabilityType
|
||||
}
|
||||
|
||||
internal val KtType.isUnit get() = isClassTypeWithClassId(DefaultTypeClassIds.UNIT)
|
||||
|
||||
+6
@@ -483,6 +483,12 @@ public class SymbolLightClassesByFqNameForLibraryTestGenerated extends AbstractS
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByFqName/nullabilityAnnotations/PlatformTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("PrimitiveBackedInlineClasses.kt")
|
||||
public void testPrimitiveBackedInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByFqName/nullabilityAnnotations/PrimitiveBackedInlineClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Primitives.kt")
|
||||
public void testPrimitives() throws Exception {
|
||||
|
||||
+6
@@ -483,6 +483,12 @@ public class SymbolLightClassesParentingForLibraryTestGenerated extends Abstract
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByFqName/nullabilityAnnotations/PlatformTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("PrimitiveBackedInlineClasses.kt")
|
||||
public void testPrimitiveBackedInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByFqName/nullabilityAnnotations/PrimitiveBackedInlineClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Primitives.kt")
|
||||
public void testPrimitives() throws Exception {
|
||||
|
||||
+6
@@ -625,6 +625,12 @@ public class SymbolLightClassesByFqNameForSourceTestGenerated extends AbstractSy
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByFqName/nullabilityAnnotations/PlatformTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("PrimitiveBackedInlineClasses.kt")
|
||||
public void testPrimitiveBackedInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByFqName/nullabilityAnnotations/PrimitiveBackedInlineClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Primitives.kt")
|
||||
public void testPrimitives() throws Exception {
|
||||
|
||||
+6
@@ -625,6 +625,12 @@ public class SymbolLightClassesParentingForSourceTestGenerated extends AbstractS
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByFqName/nullabilityAnnotations/PlatformTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("PrimitiveBackedInlineClasses.kt")
|
||||
public void testPrimitiveBackedInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByFqName/nullabilityAnnotations/PrimitiveBackedInlineClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Primitives.kt")
|
||||
public void testPrimitives() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user