Fix script properties kind in modifier checker #KT-18234 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
29f25ebeb9
commit
ecfc2236a6
@@ -68,8 +68,13 @@ public class KtProperty extends KtTypeParameterListOwnerStub<KotlinPropertyStub>
|
||||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
return !isTopLevel() && !isMember();
|
||||
}
|
||||
|
||||
public boolean isMember() {
|
||||
PsiElement parent = getParent();
|
||||
return !(parent instanceof KtFile || parent instanceof KtClassBody);
|
||||
return parent instanceof KtClassOrObject || parent instanceof KtClassBody ||
|
||||
parent instanceof KtBlockExpression && parent.getParent() instanceof KtScript;
|
||||
}
|
||||
|
||||
public boolean isTopLevel() {
|
||||
|
||||
@@ -204,7 +204,7 @@ class AnnotationChecker(private val additionalCheckers: Iterable<AdditionalAnnot
|
||||
is KtProperty -> {
|
||||
if (annotated.isLocal)
|
||||
TargetLists.T_LOCAL_VARIABLE
|
||||
else if (annotated.parent is KtClassOrObject || annotated.parent is KtClassBody)
|
||||
else if (annotated.isMember)
|
||||
TargetLists.T_MEMBER_PROPERTY(descriptor.hasBackingField(trace), annotated.hasDelegate())
|
||||
else
|
||||
TargetLists.T_TOP_LEVEL_PROPERTY(descriptor.hasBackingField(trace), annotated.hasDelegate())
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
lateinit var s: String
|
||||
|
||||
fun foo() {
|
||||
s = "Hello"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public final class LateInit : kotlin.script.templates.standard.ScriptTemplateWithArgs {
|
||||
public constructor LateInit(/*0*/ args: kotlin.Array<kotlin.String>)
|
||||
public final override /*1*/ /*fake_override*/ val args: kotlin.Array<kotlin.String>
|
||||
public final lateinit var s: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
private val s = "Hello"
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public final class PrivateVal : kotlin.script.templates.standard.ScriptTemplateWithArgs {
|
||||
public constructor PrivateVal(/*0*/ args: kotlin.Array<kotlin.String>)
|
||||
public final override /*1*/ /*fake_override*/ val args: kotlin.Array<kotlin.String>
|
||||
private final val s: kotlin.String = "Hello"
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -23642,12 +23642,24 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("LateInit.kts")
|
||||
public void testLateInit() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/script/LateInit.kts");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("NestedInnerClass.kts")
|
||||
public void testNestedInnerClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/script/NestedInnerClass.kts");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("PrivateVal.kts")
|
||||
public void testPrivateVal() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/script/PrivateVal.kts");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("resolveInitializerOfDestructuringDeclarationOnce.kts")
|
||||
public void testResolveInitializerOfDestructuringDeclarationOnce() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/script/resolveInitializerOfDestructuringDeclarationOnce.kts");
|
||||
|
||||
Reference in New Issue
Block a user