[SLC] AbstractSymbolLightClassesByFqNameTest: do not generate local declarations for libraries
^KTIJ-24067
This commit is contained in:
committed by
Space Team
parent
f9d5534689
commit
6fd79f4e2e
+23
-2
@@ -6,8 +6,11 @@
|
||||
package org.jetbrains.kotlin.light.classes.symbol.base
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.PsiModifier
|
||||
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfigurator
|
||||
import org.jetbrains.kotlin.asJava.LightClassTestCommon
|
||||
import org.jetbrains.kotlin.asJava.PsiClassRenderer
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import java.nio.file.Path
|
||||
@@ -21,7 +24,25 @@ abstract class AbstractSymbolLightClassesByFqNameTest(
|
||||
return LightClassTestCommon.getActualLightClassText(
|
||||
testDataFile.toFile(),
|
||||
{ fqName -> findLightClass(fqName, project) },
|
||||
LightClassTestCommon::removeEmptyDefaultImpls
|
||||
LightClassTestCommon::removeEmptyDefaultImpls,
|
||||
if (stopIfCompilationErrorDirectivePresent) MembersFilterForCompiledClasses else PsiClassRenderer.MembersFilter.DEFAULT,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private object MembersFilterForCompiledClasses : PsiClassRenderer.MembersFilter {
|
||||
override fun includeMethod(psiMethod: PsiMethod): Boolean {
|
||||
// Exclude methods for local functions.
|
||||
// JVM_IR generates local functions (and some lambdas) as private methods in the surrounding class.
|
||||
// Such methods are private and have names such as 'foo$...'.
|
||||
// They are not a part of the public API, and are not represented in the light classes.
|
||||
// NB this is a heuristic, and it will obviously fail for declarations such as 'private fun `foo$bar`() {}'.
|
||||
// However, it allows writing code in more or less "idiomatic" style in the light class tests
|
||||
// without thinking about private ABI and compiler optimizations.
|
||||
if (psiMethod.modifierList.hasExplicitModifier(PsiModifier.PRIVATE)) {
|
||||
return '$' !in psiMethod.name
|
||||
}
|
||||
|
||||
return super.includeMethod(psiMethod)
|
||||
}
|
||||
}
|
||||
|
||||
-8
@@ -1,12 +1,4 @@
|
||||
public final class A /* p.A*/ {
|
||||
private static final void _get_property_$localFunInPropertyAccessor();// _get_property_$localFunInPropertyAccessor()
|
||||
|
||||
private static final void _init_$localFunInConstructor();// _init_$localFunInConstructor()
|
||||
|
||||
private static final void _init_$localFunInInit();// _init_$localFunInInit()
|
||||
|
||||
private static final void memberFun$localFunInMemberFun();// memberFun$localFunInMemberFun()
|
||||
|
||||
public A(int);// .ctor(int)
|
||||
|
||||
public final int getProperty();// getProperty()
|
||||
|
||||
Reference in New Issue
Block a user