Find enclosing element for object literal in delegate #KT-8187 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
6277476573
commit
9fa16364e1
@@ -768,11 +768,14 @@ public class KtPsiUtil {
|
||||
return (KtElement) parent;
|
||||
}
|
||||
}
|
||||
if (current instanceof KtBlockExpression || current instanceof KtParameter) {
|
||||
if (current instanceof KtBlockExpression || current instanceof KtParameter || current instanceof KtValueArgument) {
|
||||
return (KtElement) current;
|
||||
}
|
||||
if (current instanceof KtValueArgument) {
|
||||
return (KtElement) current;
|
||||
if (current instanceof KtDelegatedSuperTypeEntry) {
|
||||
PsiElement grandParent = current.getParent().getParent();
|
||||
if (grandParent instanceof KtClassOrObject && !(grandParent.getParent() instanceof KtObjectLiteralExpression)) {
|
||||
return (KtElement) grandParent;
|
||||
}
|
||||
}
|
||||
|
||||
current = parent;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Test for KT-8187
|
||||
interface A {
|
||||
fun get(x: Int)
|
||||
}
|
||||
|
||||
class B : A by <error>object</error> : A {}
|
||||
|
||||
class C : A by (<error>object</error> : A {})
|
||||
|
||||
class D : A by 1 <error>+</error> (<error>object</error> : A {})
|
||||
|
||||
fun bar() {
|
||||
val <warning>e</warning> = object : A by <error>object</error> : A {} {}
|
||||
}
|
||||
@@ -224,6 +224,12 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ObjectLiteralInDelegate.kt")
|
||||
public void testObjectLiteralInDelegate() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/ObjectLiteralInDelegate.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("Objects.kt")
|
||||
public void testObjects() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/Objects.kt");
|
||||
|
||||
Reference in New Issue
Block a user