diff --git a/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/KotlinCodeBlockModificationListener.kt b/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/KotlinCodeBlockModificationListener.kt index fcaf8499b79..da577c7b223 100644 --- a/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/KotlinCodeBlockModificationListener.kt +++ b/compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/KotlinCodeBlockModificationListener.kt @@ -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 diff --git a/idea/testData/codeInsight/outOfBlock/InPropertyWithFunctionLiteral.kt b/idea/testData/codeInsight/outOfBlock/InPropertyWithFunctionLiteral.kt index 083f7a24071..7a29f2d1c2d 100644 --- a/idea/testData/codeInsight/outOfBlock/InPropertyWithFunctionLiteral.kt +++ b/idea/testData/codeInsight/outOfBlock/InPropertyWithFunctionLiteral.kt @@ -1,4 +1,4 @@ -// FALSE +// TRUE class Test { val a : () -> Int = { pri } } \ No newline at end of file diff --git a/idea/testData/codeInsight/outOfBlock/PropNotNullType_Initializer_ObjectLiteral_Fun.kt b/idea/testData/codeInsight/outOfBlock/PropNotNullType_Initializer_ObjectLiteral_Fun.kt new file mode 100644 index 00000000000..de8927a7da8 --- /dev/null +++ b/idea/testData/codeInsight/outOfBlock/PropNotNullType_Initializer_ObjectLiteral_Fun.kt @@ -0,0 +1,10 @@ +// TRUE + +// Problem with lazy initialization of nullable properties +trait Some + +val test: Some = object: Some { + fun test() { + + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_If_Fun.kt b/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_If_Fun.kt new file mode 100644 index 00000000000..89406328014 --- /dev/null +++ b/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_If_Fun.kt @@ -0,0 +1,12 @@ +// TRUE + +// Problem with lazy initialization of nullable properties + +val test: Int? = if (true) { + fun test() { + val t + } +} +else { + +} \ No newline at end of file diff --git a/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_ObjectLiteral_Fun.kt b/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_ObjectLiteral_Fun.kt new file mode 100644 index 00000000000..180d7bfd371 --- /dev/null +++ b/idea/testData/codeInsight/outOfBlock/PropNullType_Initializer_ObjectLiteral_Fun.kt @@ -0,0 +1,10 @@ +// TRUE + +// Problem with lazy initialization of nullable properties +trait Some + +val test: Some? = object: Some { + fun test() { + + } +} \ No newline at end of file diff --git a/idea/testData/codeInsight/outOfBlock/PropertyWithType_Initializer_String.kt b/idea/testData/codeInsight/outOfBlock/PropertyWithType_Initializer_String.kt index 259979a5210..d3e072aa7d9 100644 --- a/idea/testData/codeInsight/outOfBlock/PropertyWithType_Initializer_String.kt +++ b/idea/testData/codeInsight/outOfBlock/PropertyWithType_Initializer_String.kt @@ -1,3 +1,3 @@ -// FALSE +// TRUE val test: String = "" \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/codeInsight/OutOfBlockModificationTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/codeInsight/OutOfBlockModificationTestGenerated.java index 0c65ab5d331..8784233334a 100644 --- a/idea/tests/org/jetbrains/jet/plugin/codeInsight/OutOfBlockModificationTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/codeInsight/OutOfBlockModificationTestGenerated.java @@ -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");