Fix light class generation for local classes in scripts
Before this commit, we used script context for all classes defined in script. However, for local classes in scripts it's mistake, and now we generate them as usual, despite of the fact we are in script. #KT-28997 Fixed
This commit is contained in:
+7
-2
@@ -362,8 +362,13 @@ abstract class KtLightClassForSourceDeclaration(protected val classOrObject: KtC
|
||||
return InvalidLightClassDataHolder
|
||||
}
|
||||
|
||||
return classOrObject.containingKtFile.script?.let { KtLightClassForScript.getLightClassCachedValue(it).value }
|
||||
?: getLightClassCachedValue(classOrObject).value
|
||||
val containingScript = classOrObject.containingKtFile.script
|
||||
return when {
|
||||
!classOrObject.isLocal && containingScript != null ->
|
||||
KtLightClassForScript.getLightClassCachedValue(containingScript).value
|
||||
else ->
|
||||
getLightClassCachedValue(classOrObject).value
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLightClassCachedValue(classOrObject: KtClassOrObject): CachedValue<LightClassDataHolder.ForClass> {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtObjectDeclaration
|
||||
// OPTIONS: usages
|
||||
<caret>object: Any() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -1379,6 +1379,11 @@ public class FindUsagesTestGenerated extends AbstractFindUsagesTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/findUsages/kotlin/script"), Pattern.compile("^(.+)\\.0\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("anonymousObject.0.kts")
|
||||
public void testAnonymousObject() throws Exception {
|
||||
runTest("idea/testData/findUsages/kotlin/script/anonymousObject.0.kts");
|
||||
}
|
||||
|
||||
@TestMetadata("dummy.0.kts")
|
||||
public void testDummy() throws Exception {
|
||||
runTest("idea/testData/findUsages/kotlin/script/dummy.0.kts");
|
||||
|
||||
Reference in New Issue
Block a user