[FE] Replace some MUST_BE_INITIALIZED messages with MUST_BE_INITIALIZED_OR_BE_FINAL
From user point of view it's an improvement in compilation message. From technical point of view it's an introduction of new compilation diagnostic. Review: https://jetbrains.team/p/kt/reviews/9967 I'm going to deprecate `open val` case in the next few commits KT-57553. But it is always possible to suggest using `final` for `open val` case.
This commit is contained in:
+5
-7
@@ -653,8 +653,13 @@ class ControlFlowInformationProviderImpl private constructor(
|
||||
val initializers = initializersMap[pseudocode.exitInstruction] ?: return
|
||||
val declaredVariables = pseudocodeVariablesData.getDeclaredVariables(pseudocode, false)
|
||||
for (variable in declaredVariables) {
|
||||
// - If we have a primary constructor and several secondary constructors then the `if` below is called only once for the primary
|
||||
// constructor/init block
|
||||
// - If we have several secondary constructors without a primary constructor then the `if` below is called each time for every
|
||||
// secondary constructor. (init block is considered as part of each secondary constructor in that case)
|
||||
if (variable is PropertyDescriptor) {
|
||||
if (initializers.incoming.getOrNull(variable)?.definitelyInitialized() == true) continue
|
||||
trace.record(IS_DEFINITELY_NOT_ASSIGNED_IN_CONSTRUCTOR, variable)
|
||||
trace.record(IS_UNINITIALIZED, variable)
|
||||
}
|
||||
}
|
||||
@@ -1472,10 +1477,3 @@ class ControlFlowInformationProviderImpl private constructor(
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
private fun PropertyDescriptor.getEffectiveModality(languageVersionSettings: LanguageVersionSettings): Modality =
|
||||
when (languageVersionSettings.supportsFeature(LanguageFeature.TakeIntoAccountEffectivelyFinalInMustBeInitializedCheck) &&
|
||||
modality == Modality.OPEN && (containingDeclaration as? ClassDescriptor)?.modality == Modality.FINAL) {
|
||||
true -> Modality.FINAL
|
||||
false -> modality
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user