Temp workaround: force out-of-block modification for properties with nullable types

Initializers for properties with nullable types are analyzed with binding context common for all declarations.
This can cause invalid elements are left in the cache guarded with out-of-block  modification tracker. This workaround forces increment for such cases.
This commit is contained in:
Nikolay Krasko
2014-10-21 17:49:11 +04:00
parent 5cdd5f580d
commit 798a6bf689
7 changed files with 52 additions and 7 deletions
@@ -125,11 +125,6 @@ public class KotlinCodeBlockModificationListener(modificationTracker: PsiModific
}
is JetProperty -> {
val property = blockDeclarationCandidate : JetProperty
val typeReference = property.getTypeReference()
if (typeReference != null && property.getInitializer().isAncestorOf(element)) {
return true
}
for (accessor in property.getAccessors()) {
when {
accessor.getInitializer().isAncestorOf(element) -> return true
@@ -1,4 +1,4 @@
// FALSE
// TRUE
class Test {
val a : () -> Int = { <caret>pri }
}
@@ -0,0 +1,10 @@
// TRUE
// Problem with lazy initialization of nullable properties
trait Some
val test: Some = object: Some {
fun test() {
<caret>
}
}
@@ -0,0 +1,12 @@
// TRUE
// Problem with lazy initialization of nullable properties
val test: Int? = if (true) {
fun test() {
val t<caret>
}
}
else {
}
@@ -0,0 +1,10 @@
// TRUE
// Problem with lazy initialization of nullable properties
trait Some
val test: Some? = object: Some {
fun test() {
<caret>
}
}
@@ -1,3 +1,3 @@
// FALSE
// TRUE
val test: String = "<caret>"
@@ -192,6 +192,24 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
doTest(fileName);
}
@TestMetadata("PropNotNullType_Initializer_ObjectLiteral_Fun.kt")
public void testPropNotNullType_Initializer_ObjectLiteral_Fun() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/PropNotNullType_Initializer_ObjectLiteral_Fun.kt");
doTest(fileName);
}
@TestMetadata("PropNullType_Initializer_If_Fun.kt")
public void testPropNullType_Initializer_If_Fun() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_If_Fun.kt");
doTest(fileName);
}
@TestMetadata("PropNullType_Initializer_ObjectLiteral_Fun.kt")
public void testPropNullType_Initializer_ObjectLiteral_Fun() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_ObjectLiteral_Fun.kt");
doTest(fileName);
}
@TestMetadata("PropertyNoType_Initializer_String.kt")
public void testPropertyNoType_Initializer_String() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/PropertyNoType_Initializer_String.kt");