Filter out invisible fakes in KClass.properties

A user will rarely need those at the moment, and there's currently no other way
to let him filter out them by himself
This commit is contained in:
Alexander Udalov
2015-03-17 20:38:25 +03:00
parent d3abd54b06
commit a4f9fe1eaa
3 changed files with 15 additions and 1 deletions
@@ -0,0 +1,6 @@
open class A(private val p: Int)
class B : A(42)
fun box() =
if (B::class.properties.isEmpty()) "OK"
else "Fail: invisible fake overrides should not appear in KClass.properties"
@@ -2890,6 +2890,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib(fileName);
}
@TestMetadata("privateFakeOverrideFromSuperclass.kt")
public void testPrivateFakeOverrideFromSuperclass() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/privateFakeOverrideFromSuperclass.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("simpleGetProperties.kt")
public void testSimpleGetProperties() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/simpleGetProperties.kt");
@@ -17,6 +17,7 @@
package kotlin.reflect.jvm.internal
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.serialization.deserialization.findClassAcrossModuleDependencies
import kotlin.reflect.*
@@ -66,7 +67,8 @@ class KClassImpl<T>(override val jClass: Class<T>) : KCallableContainerImpl(), K
.filterIsInstance<PropertyDescriptor>()
.filter { descriptor ->
(descriptor.getExtensionReceiverParameter() != null) == extension &&
(descriptor.getKind().isReal() || !declared)
(descriptor.getKind().isReal() || !declared) &&
descriptor.getVisibility() != Visibilities.INVISIBLE_FAKE
}
.map(create)
.toList()