diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/trackers/KotlinCodeBlockModificationListener.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/trackers/KotlinCodeBlockModificationListener.kt index d65af099937..49cadb34f86 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/trackers/KotlinCodeBlockModificationListener.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/trackers/KotlinCodeBlockModificationListener.kt @@ -216,7 +216,7 @@ class KotlinCodeBlockModificationListener( fun getInsideCodeBlockModificationScope(element: PsiElement): BlockModificationScopeElement? { val lambda = element.getTopmostParentOfType() if (lambda is KtLambdaExpression) { - lambda.getTopmostParentOfType()?.let { + lambda.getTopmostParentOfType()?.getTopmostParentOfType()?.let { return BlockModificationScopeElement(it, it) } } diff --git a/idea/testData/codeInsight/outOfBlock/InSuperCtorLambda.kt b/idea/testData/codeInsight/outOfBlock/InSuperCtorLambda.kt new file mode 100644 index 00000000000..008ccd5bd1e --- /dev/null +++ b/idea/testData/codeInsight/outOfBlock/InSuperCtorLambda.kt @@ -0,0 +1,8 @@ +// OUT_OF_CODE_BLOCK: FALSE +// TYPE: 1 +// ERROR: Unresolved reference: i1 +open class Base(init: () -> Unit) + +class Some(i: Int) : Base({ + val t = i +}) \ No newline at end of file diff --git a/idea/testData/codeInsight/outOfBlock/InSuperTypeCallCallInLambdaInCall.kt b/idea/testData/codeInsight/outOfBlock/InSuperTypeCallCallInLambdaInCall.kt index c6d27d681d6..3972a3984ef 100644 --- a/idea/testData/codeInsight/outOfBlock/InSuperTypeCallCallInLambdaInCall.kt +++ b/idea/testData/codeInsight/outOfBlock/InSuperTypeCallCallInLambdaInCall.kt @@ -1,5 +1,7 @@ // OUT_OF_CODE_BLOCK: FALSE - +// ERROR: Unresolved reference: a +// ERROR: Unsupported [literal prefixes and suffixes] +// ERROR: None of the following functions can be called with the arguments supplied:
public constructor A(x: Int) defined in A
public constructor A(l: String) defined in A // Navigation from "class B: A()" should move to valid constructor even after changing type in lambda open class A(l: String) { diff --git a/idea/testData/codeInsight/outOfBlock/InSuperTypeCallInLambaInBody.kt b/idea/testData/codeInsight/outOfBlock/InSuperTypeCallInLambaInBody.kt index e18e9964dc1..0d0440e2774 100644 --- a/idea/testData/codeInsight/outOfBlock/InSuperTypeCallInLambaInBody.kt +++ b/idea/testData/codeInsight/outOfBlock/InSuperTypeCallInLambaInBody.kt @@ -1,5 +1,6 @@ // OUT_OF_CODE_BLOCK: FALSE - +// ERROR: Unresolved reference: a +// ERROR: Unsupported [literal prefixes and suffixes] open class A(a: () -> Unit) class B: A({ "1" }) \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java index b73f09b0082..dc9c07178aa 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java @@ -253,6 +253,11 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif runTest("idea/testData/codeInsight/outOfBlock/InSecondaryConstructorParameter.kt"); } + @TestMetadata("InSuperCtorLambda.kt") + public void testInSuperCtorLambda() throws Exception { + runTest("idea/testData/codeInsight/outOfBlock/InSuperCtorLambda.kt"); + } + @TestMetadata("InSuperTypeCallCallInLambdaInCall.kt") public void testInSuperTypeCallCallInLambdaInCall() throws Exception { runTest("idea/testData/codeInsight/outOfBlock/InSuperTypeCallCallInLambdaInCall.kt");