File tree Expand file tree Collapse file tree 7 files changed +46
-2
lines changed
frontend/src/org/jetbrains/kotlin
testData/diagnostics/tests/script
tests/org/jetbrains/kotlin/checkers Expand file tree Collapse file tree 7 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -68,8 +68,13 @@ public boolean isVar() {
68
68
}
69
69
70
70
public boolean isLocal () {
71
+ return !isTopLevel () && !isMember ();
72
+ }
73
+
74
+ public boolean isMember () {
71
75
PsiElement parent = getParent ();
72
- return !(parent instanceof KtFile || parent instanceof KtClassBody );
76
+ return parent instanceof KtClassOrObject || parent instanceof KtClassBody ||
77
+ parent instanceof KtBlockExpression && parent .getParent () instanceof KtScript ;
73
78
}
74
79
75
80
public boolean isTopLevel () {
Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ class AnnotationChecker(private val additionalCheckers: Iterable<AdditionalAnnot
204
204
is KtProperty -> {
205
205
if (annotated.isLocal)
206
206
TargetLists .T_LOCAL_VARIABLE
207
- else if (annotated.parent is KtClassOrObject || annotated.parent is KtClassBody )
207
+ else if (annotated.isMember )
208
208
TargetLists .T_MEMBER_PROPERTY (descriptor.hasBackingField(trace), annotated.hasDelegate())
209
209
else
210
210
TargetLists .T_TOP_LEVEL_PROPERTY (descriptor.hasBackingField(trace), annotated.hasDelegate())
Original file line number Diff line number Diff line change
1
+ lateinit var s: String
2
+
3
+ fun foo () {
4
+ s = " Hello"
5
+ }
Original file line number Diff line number Diff line change
1
+ package
2
+
3
+ public final class LateInit : kotlin.script.templates.standard.ScriptTemplateWithArgs {
4
+ public constructor LateInit(/*0*/ args: kotlin.Array<kotlin.String>)
5
+ public final override /*1*/ /*fake_override*/ val args: kotlin.Array<kotlin.String>
6
+ public final lateinit var s: kotlin.String
7
+ public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
8
+ public final fun foo(): kotlin.Unit
9
+ public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
10
+ public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
11
+ }
Original file line number Diff line number Diff line change
1
+ private val s = " Hello"
Original file line number Diff line number Diff line change
1
+ package
2
+
3
+ public final class PrivateVal : kotlin.script.templates.standard.ScriptTemplateWithArgs {
4
+ public constructor PrivateVal(/*0*/ args: kotlin.Array<kotlin.String>)
5
+ public final override /*1*/ /*fake_override*/ val args: kotlin.Array<kotlin.String>
6
+ private final val s: kotlin.String = "Hello"
7
+ public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
8
+ public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
9
+ public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
10
+ }
Original file line number Diff line number Diff line change @@ -23642,12 +23642,24 @@ public void testImports() throws Exception {
23642
23642
doTest(fileName);
23643
23643
}
23644
23644
23645
+ @TestMetadata("LateInit.kts")
23646
+ public void testLateInit() throws Exception {
23647
+ String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/script/LateInit.kts");
23648
+ doTest(fileName);
23649
+ }
23650
+
23645
23651
@TestMetadata("NestedInnerClass.kts")
23646
23652
public void testNestedInnerClass() throws Exception {
23647
23653
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/script/NestedInnerClass.kts");
23648
23654
doTest(fileName);
23649
23655
}
23650
23656
23657
+ @TestMetadata("PrivateVal.kts")
23658
+ public void testPrivateVal() throws Exception {
23659
+ String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/script/PrivateVal.kts");
23660
+ doTest(fileName);
23661
+ }
23662
+
23651
23663
@TestMetadata("resolveInitializerOfDestructuringDeclarationOnce.kts")
23652
23664
public void testResolveInitializerOfDestructuringDeclarationOnce() throws Exception {
23653
23665
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/script/resolveInitializerOfDestructuringDeclarationOnce.kts");
You can’t perform that action at this time.
0 commit comments