Minor, rename KCallableContainerImpl -> KDeclarationContainerImpl

Also rename DeclarationContainerImpl -> ClassBasedDeclarationContainer and make
non-public
This commit is contained in:
Alexander Udalov
2015-08-07 16:22:31 +03:00
parent df76695e72
commit 9f7cb752db
14 changed files with 36 additions and 36 deletions
@@ -16,7 +16,7 @@
package kotlin.reflect package kotlin.reflect
import kotlin.reflect.jvm.internal.KCallableContainerImpl import kotlin.reflect.jvm.internal.KDeclarationContainerImpl
/** /**
* Returns all functions declared in this container. * Returns all functions declared in this container.
@@ -24,7 +24,7 @@ import kotlin.reflect.jvm.internal.KCallableContainerImpl
* and the superclasses, as well as static methods declared in the class. * and the superclasses, as well as static methods declared in the class.
*/ */
public val KDeclarationContainer.functions: Collection<KFunction<*>> public val KDeclarationContainer.functions: Collection<KFunction<*>>
get() = (this as KCallableContainerImpl) get() = (this as KDeclarationContainerImpl)
.getMembers(declaredOnly = false, nonExtensions = true, extensions = true) .getMembers(declaredOnly = false, nonExtensions = true, extensions = true)
.filterIsInstance<KFunction<*>>() .filterIsInstance<KFunction<*>>()
.toList() .toList()
@@ -22,16 +22,16 @@ import kotlin.reflect.jvm.internal.JvmPropertySignature.JavaField
import kotlin.reflect.jvm.internal.JvmPropertySignature.KotlinProperty import kotlin.reflect.jvm.internal.JvmPropertySignature.KotlinProperty
abstract class DescriptorBasedProperty<out R> protected constructor( abstract class DescriptorBasedProperty<out R> protected constructor(
internal val container: KCallableContainerImpl, internal val container: KDeclarationContainerImpl,
name: String, name: String,
signature: String, signature: String,
descriptorInitialValue: PropertyDescriptor? descriptorInitialValue: PropertyDescriptor?
) : KCallableImpl<R> { ) : KCallableImpl<R> {
constructor(container: KCallableContainerImpl, name: String, signature: String) : this( constructor(container: KDeclarationContainerImpl, name: String, signature: String) : this(
container, name, signature, null container, name, signature, null
) )
constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : this( constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : this(
container, container,
descriptor.name.asString(), descriptor.name.asString(),
RuntimeTypeMapper.mapPropertySignature(descriptor).asString(), RuntimeTypeMapper.mapPropertySignature(descriptor).asString(),
@@ -28,7 +28,7 @@ import kotlin.reflect.KClass
import kotlin.reflect.KFunction import kotlin.reflect.KFunction
import kotlin.reflect.KotlinReflectionInternalError import kotlin.reflect.KotlinReflectionInternalError
class KClassImpl<T : Any>(override val jClass: Class<T>) : KCallableContainerImpl(), KClass<T>, KAnnotatedElementImpl { class KClassImpl<T : Any>(override val jClass: Class<T>) : KDeclarationContainerImpl(), KClass<T>, KAnnotatedElementImpl {
val descriptor by ReflectProperties.lazySoft { val descriptor by ReflectProperties.lazySoft {
val classId = classId val classId = classId
@@ -32,11 +32,11 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.JvmType.PrimitiveType.
import java.lang.reflect.Constructor import java.lang.reflect.Constructor
import java.lang.reflect.Field import java.lang.reflect.Field
import java.lang.reflect.Method import java.lang.reflect.Method
import kotlin.jvm.internal.DeclarationContainerImpl import kotlin.jvm.internal.ClassBasedDeclarationContainer
import kotlin.reflect.KCallable import kotlin.reflect.KCallable
import kotlin.reflect.KotlinReflectionInternalError import kotlin.reflect.KotlinReflectionInternalError
abstract class KCallableContainerImpl : DeclarationContainerImpl { abstract class KDeclarationContainerImpl : ClassBasedDeclarationContainer {
// Note: this is stored here on a soft reference to prevent GC from destroying the weak reference to it in the moduleByClassLoader cache // Note: this is stored here on a soft reference to prevent GC from destroying the weak reference to it in the moduleByClassLoader cache
val moduleData by ReflectProperties.lazySoft { val moduleData by ReflectProperties.lazySoft {
jClass.getOrCreateModule() jClass.getOrCreateModule()
@@ -66,7 +66,7 @@ abstract class KCallableContainerImpl : DeclarationContainerImpl {
} }
override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, data: Unit): KCallable<*>? { override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, data: Unit): KCallable<*>? {
return if (skipCallable(descriptor)) null else KFunctionImpl(this@KCallableContainerImpl, descriptor) return if (skipCallable(descriptor)) null else KFunctionImpl(this@KDeclarationContainerImpl, descriptor)
} }
override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, data: Unit): KCallable<*>? { override fun visitConstructorDescriptor(descriptor: ConstructorDescriptor, data: Unit): KCallable<*>? {
@@ -24,7 +24,7 @@ import kotlin.reflect.KotlinReflectionInternalError
class KFunctionFromReferenceImpl( class KFunctionFromReferenceImpl(
val reference: FunctionReference val reference: FunctionReference
): KFunctionImpl( ): KFunctionImpl(
reference.getOwner() as? KCallableContainerImpl ?: EmptyContainerForLocal, reference.getOwner() as? KDeclarationContainerImpl ?: EmptyContainerForLocal,
reference.getName(), reference.getName(),
reference.getSignature() reference.getSignature()
) { ) {
@@ -59,7 +59,7 @@ class KFunctionFromReferenceImpl(
override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?, p19: Any?, p20: Any?, p21: Any?, p22: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22) override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?, p19: Any?, p20: Any?, p21: Any?, p22: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22)
} }
object EmptyContainerForLocal : KCallableContainerImpl() { object EmptyContainerForLocal : KDeclarationContainerImpl() {
override val jClass: Class<*> override val jClass: Class<*>
get() = fail() get() = fail()
@@ -31,15 +31,15 @@ import kotlin.reflect.jvm.internal.JvmFunctionSignature.JavaMethod
import kotlin.reflect.jvm.internal.JvmFunctionSignature.KotlinFunction import kotlin.reflect.jvm.internal.JvmFunctionSignature.KotlinFunction
open class KFunctionImpl protected constructor( open class KFunctionImpl protected constructor(
private val container: KCallableContainerImpl, private val container: KDeclarationContainerImpl,
name: String, name: String,
signature: String, signature: String,
descriptorInitialValue: FunctionDescriptor? descriptorInitialValue: FunctionDescriptor?
) : KFunction<Any?>, KCallableImpl<Any?>, FunctionImpl(), ) : KFunction<Any?>, KCallableImpl<Any?>, FunctionImpl(),
KLocalFunction<Any?>, KMemberFunction<Any, Any?>, KTopLevelExtensionFunction<Any?, Any?>, KTopLevelFunction<Any?> { KLocalFunction<Any?>, KMemberFunction<Any, Any?>, KTopLevelExtensionFunction<Any?, Any?>, KTopLevelFunction<Any?> {
constructor(container: KCallableContainerImpl, name: String, signature: String) : this(container, name, signature, null) constructor(container: KDeclarationContainerImpl, name: String, signature: String) : this(container, name, signature, null)
constructor(container: KCallableContainerImpl, descriptor: FunctionDescriptor) : this( constructor(container: KDeclarationContainerImpl, descriptor: FunctionDescriptor) : this(
container, descriptor.name.asString(), RuntimeTypeMapper.mapSignature(descriptor).asString(), descriptor container, descriptor.name.asString(), RuntimeTypeMapper.mapSignature(descriptor).asString(), descriptor
) )
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope
import kotlin.jvm.internal.KotlinPackage import kotlin.jvm.internal.KotlinPackage
import kotlin.reflect.KPackage import kotlin.reflect.KPackage
class KPackageImpl(override val jClass: Class<*>) : KCallableContainerImpl(), KPackage { class KPackageImpl(override val jClass: Class<*>) : KDeclarationContainerImpl(), KPackage {
val descriptor by ReflectProperties.lazySoft { val descriptor by ReflectProperties.lazySoft {
val moduleData = jClass.getOrCreateModule() val moduleData = jClass.getOrCreateModule()
val fqName = jClass.classId.getPackageFqName() val fqName = jClass.classId.getPackageFqName()
@@ -23,9 +23,9 @@ import kotlin.reflect.KMutableProperty0
import kotlin.reflect.KProperty0 import kotlin.reflect.KProperty0
open class KProperty0Impl<out R> : DescriptorBasedProperty<R>, KProperty0<R>, KPropertyImpl<R> { open class KProperty0Impl<out R> : DescriptorBasedProperty<R>, KProperty0<R>, KPropertyImpl<R> {
constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
override val getter by ReflectProperties.lazy { Getter(this) } override val getter by ReflectProperties.lazy { Getter(this) }
@@ -37,9 +37,9 @@ open class KProperty0Impl<out R> : DescriptorBasedProperty<R>, KProperty0<R>, KP
} }
open class KMutableProperty0Impl<R> : KProperty0Impl<R>, KMutableProperty0<R>, KMutablePropertyImpl<R> { open class KMutableProperty0Impl<R> : KProperty0Impl<R>, KMutableProperty0<R>, KMutablePropertyImpl<R> {
constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
override val setter by ReflectProperties.lazy { Setter(this) } override val setter by ReflectProperties.lazy { Setter(this) }
@@ -54,7 +54,7 @@ open class KMutableProperty0Impl<R> : KProperty0Impl<R>, KMutableProperty0<R>, K
class KProperty0FromReferenceImpl( class KProperty0FromReferenceImpl(
val reference: PropertyReference0 val reference: PropertyReference0
) : KProperty0Impl<Any?>( ) : KProperty0Impl<Any?>(
reference.owner as KCallableContainerImpl, reference.owner as KDeclarationContainerImpl,
reference.name, reference.name,
reference.signature reference.signature
) { ) {
@@ -67,7 +67,7 @@ class KProperty0FromReferenceImpl(
class KMutableProperty0FromReferenceImpl( class KMutableProperty0FromReferenceImpl(
val reference: MutablePropertyReference0 val reference: MutablePropertyReference0
) : KMutableProperty0Impl<Any?>( ) : KMutableProperty0Impl<Any?>(
reference.owner as KCallableContainerImpl, reference.owner as KDeclarationContainerImpl,
reference.name, reference.name,
reference.signature reference.signature
) { ) {
@@ -23,9 +23,9 @@ import kotlin.reflect.KMutableProperty1
import kotlin.reflect.KProperty1 import kotlin.reflect.KProperty1
open class KProperty1Impl<T, out R> : DescriptorBasedProperty<R>, KProperty1<T, R>, KPropertyImpl<R> { open class KProperty1Impl<T, out R> : DescriptorBasedProperty<R>, KProperty1<T, R>, KPropertyImpl<R> {
constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
override val getter by ReflectProperties.lazy { Getter(this) } override val getter by ReflectProperties.lazy { Getter(this) }
@@ -37,9 +37,9 @@ open class KProperty1Impl<T, out R> : DescriptorBasedProperty<R>, KProperty1<T,
} }
open class KMutableProperty1Impl<T, R> : KProperty1Impl<T, R>, KMutableProperty1<T, R>, KMutablePropertyImpl<R> { open class KMutableProperty1Impl<T, R> : KProperty1Impl<T, R>, KMutableProperty1<T, R>, KMutablePropertyImpl<R> {
constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
override val setter by ReflectProperties.lazy { Setter(this) } override val setter by ReflectProperties.lazy { Setter(this) }
@@ -54,7 +54,7 @@ open class KMutableProperty1Impl<T, R> : KProperty1Impl<T, R>, KMutableProperty1
class KProperty1FromReferenceImpl( class KProperty1FromReferenceImpl(
val reference: PropertyReference1 val reference: PropertyReference1
) : KProperty1Impl<Any?, Any?>( ) : KProperty1Impl<Any?, Any?>(
reference.owner as KCallableContainerImpl, reference.owner as KDeclarationContainerImpl,
reference.name, reference.name,
reference.signature reference.signature
) { ) {
@@ -67,7 +67,7 @@ class KProperty1FromReferenceImpl(
class KMutableProperty1FromReferenceImpl( class KMutableProperty1FromReferenceImpl(
val reference: MutablePropertyReference1 val reference: MutablePropertyReference1
) : KMutableProperty1Impl<Any?, Any?>( ) : KMutableProperty1Impl<Any?, Any?>(
reference.owner as KCallableContainerImpl, reference.owner as KDeclarationContainerImpl,
reference.name, reference.name,
reference.signature reference.signature
) { ) {
@@ -21,9 +21,9 @@ import kotlin.reflect.KMutableProperty2
import kotlin.reflect.KProperty2 import kotlin.reflect.KProperty2
open class KProperty2Impl<D, E, out R> : DescriptorBasedProperty<R>, KProperty2<D, E, R>, KPropertyImpl<R> { open class KProperty2Impl<D, E, out R> : DescriptorBasedProperty<R>, KProperty2<D, E, R>, KPropertyImpl<R> {
constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
override val getter by ReflectProperties.lazy { Getter(this) } override val getter by ReflectProperties.lazy { Getter(this) }
@@ -35,9 +35,9 @@ open class KProperty2Impl<D, E, out R> : DescriptorBasedProperty<R>, KProperty2<
} }
class KMutableProperty2Impl<D, E, R> : KProperty2Impl<D, E, R>, KMutableProperty2<D, E, R>, KMutablePropertyImpl<R> { class KMutableProperty2Impl<D, E, R> : KProperty2Impl<D, E, R>, KMutableProperty2<D, E, R>, KMutablePropertyImpl<R> {
constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KDeclarationContainerImpl, name: String, signature: String) : super(container, name, signature)
constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) constructor(container: KDeclarationContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor)
override val setter by ReflectProperties.lazy { Setter(this) } override val setter by ReflectProperties.lazy { Setter(this) }
@@ -27,7 +27,7 @@ import kotlin.reflect.KProperty
interface KPropertyImpl<out R> : KProperty<R>, KCallableImpl<R> { interface KPropertyImpl<out R> : KProperty<R>, KCallableImpl<R> {
val javaField: Field? val javaField: Field?
val container: KCallableContainerImpl val container: KDeclarationContainerImpl
override val getter: Getter<R> override val getter: Getter<R>
@@ -69,12 +69,12 @@ sealed class JvmFunctionSignature {
} }
open class BuiltInFunction(private val signature: String) : JvmFunctionSignature() { open class BuiltInFunction(private val signature: String) : JvmFunctionSignature() {
open fun getMember(container: KCallableContainerImpl): Member? = null open fun getMember(container: KDeclarationContainerImpl): Member? = null
override fun asString(): String = signature override fun asString(): String = signature
class Predefined(signature: String, private val member: Member): BuiltInFunction(signature) { class Predefined(signature: String, private val member: Member): BuiltInFunction(signature) {
override fun getMember(container: KCallableContainerImpl): Member = member override fun getMember(container: KDeclarationContainerImpl): Member = member
} }
} }
} }
@@ -18,6 +18,6 @@ package kotlin.jvm.internal
import kotlin.reflect.KDeclarationContainer import kotlin.reflect.KDeclarationContainer
public interface DeclarationContainerImpl : KDeclarationContainer { interface ClassBasedDeclarationContainer : KDeclarationContainer {
public val jClass: Class<*> public val jClass: Class<*>
} }
@@ -20,7 +20,7 @@ import kotlin.reflect.KCallable
import kotlin.reflect.KClass import kotlin.reflect.KClass
import kotlin.reflect.KFunction import kotlin.reflect.KFunction
public class ClassReference(override val jClass: Class<*>) : KClass<Any>, DeclarationContainerImpl { public class ClassReference(override val jClass: Class<*>) : KClass<Any>, ClassBasedDeclarationContainer {
override val simpleName: String? override val simpleName: String?
get() = error() get() = error()