Determine enclosing element correctly inside base constructor

So #KT-17680 Fixed
So #KT-18740 Fixed
So EA-76201 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-09-28 18:41:37 +03:00
parent b839081349
commit 5c4c77a80a
4 changed files with 52 additions and 1 deletions
@@ -854,7 +854,7 @@ public class KtPsiUtil {
return (KtElement) current;
}
}
if (current instanceof KtDelegatedSuperTypeEntry) {
if (current instanceof KtDelegatedSuperTypeEntry || current instanceof KtSuperTypeCallEntry) {
PsiElement grandParent = current.getParent().getParent();
if (grandParent instanceof KtClassOrObject && !(grandParent.getParent() instanceof KtObjectLiteralExpression)) {
return (KtElement) grandParent;
@@ -0,0 +1,25 @@
package test
interface A {
fun get(x : Int)
}
open class B(val a: A)
class C : B(object : A {
override fun get(x : Int) {}
})
//package test
//public interface A defined in test
//public abstract fun get(x: kotlin.Int): kotlin.Unit defined in test.A
//value-parameter x: kotlin.Int defined in test.A.get
//public open class B defined in test
//public constructor B(a: test.A) defined in test.B
//value-parameter a: test.A defined in test.B.<init>
//public final class C : test.B defined in test
//public constructor C() defined in test.C
//local final class <no name provided> : test.A defined in test.C.<init>
//public constructor <no name provided>() defined in test.C.<init>.<no name provided>
//public open fun get(x: kotlin.Int): kotlin.Unit defined in test.C.<init>.<no name provided>
//value-parameter x: kotlin.Int defined in test.C.<init>.<no name provided>.get
@@ -0,0 +1,14 @@
package test
open class B(val foo: () -> Unit)
class C : B({
})
//package test
//public open class B defined in test
//public constructor B(foo: () -> kotlin.Unit) defined in test.B
//value-parameter foo: () -> kotlin.Unit defined in test.B.<init>
//public final class C : test.B defined in test
//public constructor C() defined in test.C
@@ -36,6 +36,12 @@ public class AdditionalResolveDescriptorRendererTestGenerated extends AbstractAd
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/resolve/additionalLazyResolve"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("anonymousObjectInBaseConstructor.kt")
public void testAnonymousObjectInBaseConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/additionalLazyResolve/anonymousObjectInBaseConstructor.kt");
doTest(fileName);
}
@TestMetadata("anonymousObjectInClassInitializer.kt")
public void testAnonymousObjectInClassInitializer() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/additionalLazyResolve/anonymousObjectInClassInitializer.kt");
@@ -48,6 +54,12 @@ public class AdditionalResolveDescriptorRendererTestGenerated extends AbstractAd
doTest(fileName);
}
@TestMetadata("functionLiteralInBaseConstructor.kt")
public void testFunctionLiteralInBaseConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/additionalLazyResolve/functionLiteralInBaseConstructor.kt");
doTest(fileName);
}
@TestMetadata("localClassInClassInitializer.kt")
public void testLocalClassInClassInitializer() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/additionalLazyResolve/localClassInClassInitializer.kt");