KT-56835 [SLC] Mark property$delegate fields as final and @NotNull

This commit is contained in:
Pavel Mikhailovskii
2023-02-22 09:40:32 +00:00
committed by Space Team
parent 6ac562a19d
commit de1927abb6
5 changed files with 26 additions and 10 deletions
@@ -98,12 +98,10 @@ internal class SymbolLightFieldForProperty private constructor(
in GranularModifiersBox.VISIBILITY_MODIFIERS -> GranularModifiersBox.computeVisibilityForMember(ktModule, propertySymbolPointer) in GranularModifiersBox.VISIBILITY_MODIFIERS -> GranularModifiersBox.computeVisibilityForMember(ktModule, propertySymbolPointer)
in GranularModifiersBox.MODALITY_MODIFIERS -> { in GranularModifiersBox.MODALITY_MODIFIERS -> {
val modality = withPropertySymbol { propertySymbol -> val modality = withPropertySymbol { propertySymbol ->
if (propertySymbol.isVal) { if (propertySymbol.isVal || propertySymbol.isDelegatedProperty) {
PsiModifier.FINAL PsiModifier.FINAL
} else { } else {
propertySymbol.computeSimpleModality()?.takeIf { propertySymbol.computeSimpleModality()?.takeIf { it != PsiModifier.FINAL }
it != PsiModifier.FINAL || isTopLevel && propertySymbol.isDelegatedProperty
}
} }
} }
@@ -154,10 +152,10 @@ internal class SymbolLightFieldForProperty private constructor(
), ),
additionalAnnotationsProvider = NullabilityAnnotationsProvider { additionalAnnotationsProvider = NullabilityAnnotationsProvider {
withPropertySymbol { propertySymbol -> withPropertySymbol { propertySymbol ->
if (!(propertySymbol is KtKotlinPropertySymbol && propertySymbol.isLateInit)) { when {
getTypeNullability(propertySymbol.returnType) propertySymbol.isDelegatedProperty -> NullabilityType.NotNull
} else { !(propertySymbol is KtKotlinPropertySymbol && propertySymbol.isLateInit) -> getTypeNullability(propertySymbol.returnType)
NullabilityType.Unknown else -> NullabilityType.Unknown
} }
} }
} }
@@ -5,6 +5,9 @@ public static abstract class Base /* Container.Base*/ {
@org.jetbrains.annotations.NotNull() @org.jetbrains.annotations.NotNull()
private final Container.Delegate<java.lang.String> b$delegate; private final Container.Delegate<java.lang.String> b$delegate;
@org.jetbrains.annotations.NotNull()
private final Container.Delegate<java.lang.String> mutable$delegate;
@org.jetbrains.annotations.NotNull() @org.jetbrains.annotations.NotNull()
private final java.lang.String c = "" /* initializer type: java.lang.String */; private final java.lang.String c = "" /* initializer type: java.lang.String */;
@@ -20,7 +23,12 @@ public static abstract class Base /* Container.Base*/ {
@org.jetbrains.annotations.NotNull() @org.jetbrains.annotations.NotNull()
public java.lang.String getC();// getC() public java.lang.String getC();// getC()
@org.jetbrains.annotations.Nullable()
public final java.lang.String getMutable();// getMutable()
public Base();// .ctor() public Base();// .ctor()
public final void setMutable(@org.jetbrains.annotations.Nullable() java.lang.String);// setMutable(java.lang.String)
} }
public static final class Companion /* Container.Companion*/ { public static final class Companion /* Container.Companion*/ {
@@ -5,6 +5,9 @@ public static abstract class Base /* Container.Base*/ {
@org.jetbrains.annotations.NotNull() @org.jetbrains.annotations.NotNull()
private final Container.Delegate b$delegate; private final Container.Delegate b$delegate;
@org.jetbrains.annotations.NotNull()
private final Container.Delegate mutable$delegate;
@org.jetbrains.annotations.NotNull() @org.jetbrains.annotations.NotNull()
private final java.lang.String c; private final java.lang.String c;
@@ -20,7 +23,12 @@ public static abstract class Base /* Container.Base*/ {
@org.jetbrains.annotations.NotNull() @org.jetbrains.annotations.NotNull()
public java.lang.String getC();// getC() public java.lang.String getC();// getC()
@org.jetbrains.annotations.Nullable()
public final java.lang.String getMutable();// getMutable()
public Base();// .ctor() public Base();// .ctor()
public final void setMutable(@org.jetbrains.annotations.Nullable() java.lang.String);// setMutable(java.lang.String)
} }
public static final class Companion /* Container.Companion*/ { public static final class Companion /* Container.Companion*/ {
@@ -15,6 +15,7 @@ class Container {
abstract class Base { abstract class Base {
val a: String by delegate() val a: String by delegate()
var mutable: String? by delegate()
open val b: String by delegate() open val b: String by delegate()
open val c: String = "" open val c: String = ""
abstract val d: String abstract val d: String
@@ -2,6 +2,9 @@ public final class PropertiesKt /* PropertiesKt*/ {
@org.jetbrains.annotations.NotNull() @org.jetbrains.annotations.NotNull()
private static final error.NonExistentClass delegatedProp$delegate; private static final error.NonExistentClass delegatedProp$delegate;
@org.jetbrains.annotations.NotNull()
private static final error.NonExistentClass delegatedProp2$delegate;
@org.jetbrains.annotations.NotNull() @org.jetbrains.annotations.NotNull()
private static final java.lang.Object arrayConst; private static final java.lang.Object arrayConst;
@@ -38,8 +41,6 @@ public final class PropertiesKt /* PropertiesKt*/ {
@org.jetbrains.annotations.Nullable() @org.jetbrains.annotations.Nullable()
private static java.lang.Integer isEmptyInt; private static java.lang.Integer isEmptyInt;
private static final error.NonExistentClass delegatedProp2$delegate;
private static final error.NonExistentClass intConst = 30 /* initializer type: int */; private static final error.NonExistentClass intConst = 30 /* initializer type: int */;
private static final int f1 = 2 /* initializer type: int */; private static final int f1 = 2 /* initializer type: int */;