Enforce analysis inside top-level property initializer
Relates to #KT-36460
This commit is contained in:
+1
-4
@@ -254,10 +254,7 @@ class KotlinCodeBlockModificationListener(
|
|||||||
(element !is KtAnnotated || element.annotationEntries.isEmpty())
|
(element !is KtAnnotated || element.annotationEntries.isEmpty())
|
||||||
}
|
}
|
||||||
?.let { expression ->
|
?.let { expression ->
|
||||||
val declaration = if (blockDeclaration.initializer != null)
|
val declaration =
|
||||||
blockDeclaration
|
|
||||||
else
|
|
||||||
// property could be initialized on a class level
|
|
||||||
KtPsiUtil.getTopmostParentOfTypes(blockDeclaration, KtClass::class.java) as? KtElement ?:
|
KtPsiUtil.getTopmostParentOfTypes(blockDeclaration, KtClass::class.java) as? KtElement ?:
|
||||||
// ktFile to check top level property declarations
|
// ktFile to check top level property declarations
|
||||||
return null
|
return null
|
||||||
|
|||||||
+4
-1
@@ -1,4 +1,7 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// TODO NOTE: [VD] Temporary workaround for KT-36460
|
||||||
|
// SKIP_ANALYZE_CHECK
|
||||||
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
|
||||||
// ERROR: Unresolved reference: a
|
// ERROR: Unresolved reference: a
|
||||||
|
|
||||||
interface Some
|
interface Some
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// TODO NOTE: [VD] Temporary workaround for KT-36460
|
||||||
|
// SKIP_ANALYZE_CHECK
|
||||||
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
|
||||||
// ERROR: This variable must either have a type annotation or be initialized
|
// ERROR: This variable must either have a type annotation or be initialized
|
||||||
// ERROR: Type mismatch: inferred type is Unit but Int? was expected
|
// ERROR: Type mismatch: inferred type is Unit but Int? was expected
|
||||||
|
// ERROR: Type mismatch: inferred type is Unit but Int? was expected
|
||||||
|
|
||||||
val test: Int? = if (true) {
|
val test: Int? = if (true) {
|
||||||
fun test() {
|
fun test() {
|
||||||
|
|||||||
+5
-3
@@ -1,8 +1,10 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// TODO NOTE: [VD] Temporary workaround for KT-36460
|
||||||
|
// SKIP_ANALYZE_CHECK
|
||||||
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
|
||||||
// Problem with lazy initialization of nullable properties
|
// Problem with lazy initialization of nullable properties
|
||||||
|
|
||||||
// TODO: Investigate
|
// ERROR: Unresolved reference: a
|
||||||
// --ERROR: Unresolved reference: q
|
|
||||||
interface Some
|
interface Some
|
||||||
|
|
||||||
val test: Some? = object: Some {
|
val test: Some? = object: Some {
|
||||||
|
|||||||
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
// OUT_OF_CODE_BLOCK: FALSE
|
// TODO NOTE: [VD] Temporary workaround for KT-36460
|
||||||
|
// SKIP_ANALYZE_CHECK
|
||||||
|
// OUT_OF_CODE_BLOCK: TRUE
|
||||||
|
|
||||||
val test: String = "<caret>"
|
val test: String = "<caret>"
|
||||||
Reference in New Issue
Block a user