Unused symbol: never use VALUE_ARGUMENT scope for members
So #KT-10546 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
5c4e034171
commit
7e3d3bde74
@@ -818,9 +818,25 @@ public class KtPsiUtil {
|
||||
return (KtElement) parent;
|
||||
}
|
||||
}
|
||||
if (current instanceof KtBlockExpression || current instanceof KtParameter || current instanceof KtValueArgument) {
|
||||
if (current instanceof KtBlockExpression || current instanceof KtParameter) {
|
||||
return (KtElement) current;
|
||||
}
|
||||
if (current instanceof KtValueArgument) {
|
||||
// for members, value argument is never enough, see KT-10546
|
||||
if (declaration instanceof KtProperty) {
|
||||
if (((KtProperty) declaration).isLocal()) {
|
||||
return (KtElement) current;
|
||||
}
|
||||
}
|
||||
else if (declaration instanceof KtFunction) {
|
||||
if (((KtFunction) declaration).isLocal()) {
|
||||
return (KtElement) current;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return (KtElement) current;
|
||||
}
|
||||
}
|
||||
if (current instanceof KtDelegatedSuperTypeEntry) {
|
||||
PsiElement grandParent = current.getParent().getParent();
|
||||
if (grandParent instanceof KtClassOrObject && !(grandParent.getParent() instanceof KtObjectLiteralExpression)) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() {
|
||||
val y = listOf(object {
|
||||
val <caret>value = 0
|
||||
})[0]
|
||||
y.value
|
||||
}
|
||||
@@ -1850,6 +1850,12 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/unusedSymbol"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inAnonymous.kt")
|
||||
public void testInAnonymous() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/unusedSymbol/inAnonymous.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("internal.kt")
|
||||
public void testInternal() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/unusedSymbol/internal.kt");
|
||||
|
||||
Reference in New Issue
Block a user