[FE] Don't issue a deprecation warning for open val deferred init when the property is unconditionally effectively final
^KT-61228 Fixed Review: https://jetbrains.team/p/kt/reviews/11694/timeline
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
// FIR_IDENTICAL
|
||||
// DIAGNOSTICS: -DEBUG_INFO_LEAKING_THIS
|
||||
// LANGUAGE:-TakeIntoAccountEffectivelyFinalInMustBeInitializedCheck
|
||||
// LANGUAGE:+ProhibitOpenValDeferredInitialization
|
||||
|
||||
// Invalid combination of language feature flags. The user enabled 2.0 language flag (+ProhibitOpenValDeferredInitialization) and disabled
|
||||
// 1.9 language flag (-TakeIntoAccountEffectivelyFinalInMustBeInitializedCheck) => It's only possible if users manually set `-XXLanguage` =>
|
||||
// Technically, it's UB (undefined behaviour)
|
||||
//
|
||||
// On one hand, suppose that you have 1.9.0 compiler with -XXLanguage:-TakeIntoAccountEffectivelyFinalInMustBeInitializedCheck and then you
|
||||
// bump your compiler version to 1.9.20. It's not nice that you will get this compilation error considering that you didn't have a warning
|
||||
// => so probably we shouldn't report a error here
|
||||
//
|
||||
// But on the other hand, the error is expected by the combination of feature flags (we prohibit open val deferred initialization and
|
||||
// since we don't take effectively final into account) => we must be report a error
|
||||
//
|
||||
// Anyway, it's UB. Users shouldn't manually tune `-XXLanguage`
|
||||
|
||||
interface Base {
|
||||
val foo: Int
|
||||
}
|
||||
|
||||
class Foo : Base {
|
||||
<!MUST_BE_INITIALIZED_OR_FINAL_OR_ABSTRACT!>override val foo: Int<!>
|
||||
|
||||
init {
|
||||
foo = 1
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// FIR_IDENTICAL
|
||||
// DIAGNOSTICS: -DEBUG_INFO_LEAKING_THIS
|
||||
// LANGUAGE:+TakeIntoAccountEffectivelyFinalInMustBeInitializedCheck
|
||||
// LANGUAGE:+ProhibitOpenValDeferredInitialization
|
||||
interface Base {
|
||||
val foo: Int
|
||||
}
|
||||
|
||||
class Foo : Base {
|
||||
override val foo: Int
|
||||
|
||||
init {
|
||||
foo = 1
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// FIR_IDENTICAL
|
||||
// DIAGNOSTICS: -DEBUG_INFO_LEAKING_THIS
|
||||
// LANGUAGE:-TakeIntoAccountEffectivelyFinalInMustBeInitializedCheck
|
||||
// LANGUAGE:-ProhibitOpenValDeferredInitialization
|
||||
// KT-61228 case
|
||||
interface Base {
|
||||
val foo: Int
|
||||
}
|
||||
|
||||
class Foo : Base {
|
||||
override val foo: Int
|
||||
|
||||
init {
|
||||
foo = 1
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// FIR_IDENTICAL
|
||||
// DIAGNOSTICS: -DEBUG_INFO_LEAKING_THIS
|
||||
// LANGUAGE:+TakeIntoAccountEffectivelyFinalInMustBeInitializedCheck
|
||||
// LANGUAGE:-ProhibitOpenValDeferredInitialization
|
||||
interface Base {
|
||||
val foo: Int
|
||||
}
|
||||
|
||||
class Foo : Base {
|
||||
override val foo: Int
|
||||
|
||||
init {
|
||||
foo = 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user