Minor. rename getObjectType to getCompanionObjectType

This commit is contained in:
Stanislav Erokhin
2015-11-16 16:40:44 +03:00
parent c7f7ba72b8
commit b4fe62e53e
6 changed files with 20 additions and 20 deletions
@@ -426,7 +426,7 @@ public abstract class AnnotationCodegen {
for (ConstantValue<?> value : values) {
if (value instanceof EnumValue) {
ClassDescriptor enumEntry = ((EnumValue) value).getValue();
KotlinType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry);
KotlinType classObjectType = DescriptorUtilsKt.getCompanionObjectType(enumEntry);
if (classObjectType != null) {
if ("java/lang/annotation/ElementType".equals(typeMapper.mapType(classObjectType).getInternalName())) {
result.add(ElementType.valueOf(enumEntry.getName().asString()));
@@ -454,7 +454,7 @@ public abstract class AnnotationCodegen {
ConstantValue<?> compileTimeConstant = valueArguments.iterator().next();
if (compileTimeConstant instanceof EnumValue) {
ClassDescriptor enumEntry = ((EnumValue) compileTimeConstant).getValue();
KotlinType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry);
KotlinType classObjectType = DescriptorUtilsKt.getCompanionObjectType(enumEntry);
if (classObjectType != null) {
if ("java/lang/annotation/RetentionPolicy".equals(typeMapper.mapType(classObjectType).getInternalName())) {
return RetentionPolicy.valueOf(enumEntry.getName().asString());
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils.isStaticNestedClass
import org.jetbrains.kotlin.resolve.LibrarySourceHacks
import org.jetbrains.kotlin.resolve.calls.tasks.createSynthesizedInvokes
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassObjectType
import org.jetbrains.kotlin.resolve.descriptorUtil.hasCompanionObject
import org.jetbrains.kotlin.resolve.scopes.HierarchicalScope
import org.jetbrains.kotlin.resolve.scopes.LexicalChainedScope
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
@@ -181,7 +181,7 @@ private object VariableCollector : CallableDescriptorCollector<VariableDescripto
private fun getFakeDescriptorForObject(scope: HierarchicalScope, name: Name, location: LookupLocation): VariableDescriptor? {
val classifier = scope.findClassifier(name, location)
if (classifier !is ClassDescriptor || !classifier.hasClassObjectType) return null
if (classifier !is ClassDescriptor || !classifier.hasCompanionObject) return null
return FakeCallableDescriptorForObject(classifier)
}
@@ -17,9 +17,9 @@
package org.jetbrains.kotlin.resolve.calls.util
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType
import org.jetbrains.kotlin.resolve.descriptorUtil.companionObjectType
import org.jetbrains.kotlin.resolve.descriptorUtil.getClassObjectReferenceTarget
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassObjectType
import org.jetbrains.kotlin.resolve.descriptorUtil.hasCompanionObject
import org.jetbrains.kotlin.types.KotlinType
import java.util.Collections
@@ -28,7 +28,7 @@ public class FakeCallableDescriptorForObject(
) : DeclarationDescriptorWithVisibility by classDescriptor.getClassObjectReferenceTarget(), VariableDescriptor {
init {
assert(classDescriptor.hasClassObjectType) {
assert(classDescriptor.hasCompanionObject) {
"FakeCallableDescriptorForObject can be created only for objects, classes with companion object or enum entries: $classDescriptor"
}
@@ -52,7 +52,7 @@ public class FakeCallableDescriptorForObject(
override fun getOverriddenDescriptors(): Set<CallableDescriptor> = Collections.emptySet()
override fun getType(): KotlinType = classDescriptor.classObjectType!!
override fun getType(): KotlinType = classDescriptor.companionObjectType!!
override fun isVar() = false
@@ -27,8 +27,8 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingContext.*
import org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName
import org.jetbrains.kotlin.resolve.bindingContextUtil.recordScope
import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassObjectType
import org.jetbrains.kotlin.resolve.descriptorUtil.companionObjectType
import org.jetbrains.kotlin.resolve.descriptorUtil.hasCompanionObject
import org.jetbrains.kotlin.resolve.scopes.ChainedScope
import org.jetbrains.kotlin.resolve.scopes.FilteringScope
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils
@@ -112,7 +112,7 @@ class ClassifierQualifier(
val scopes = ArrayList<MemberScope>(3)
val classObjectTypeScope = classifier.classObjectType?.memberScope?.let {
val classObjectTypeScope = classifier.companionObjectType?.memberScope?.let {
FilteringScope(it) { it !is ClassDescriptor }
}
scopes.addIfNotNull(classObjectTypeScope)
@@ -150,7 +150,7 @@ fun createClassifierQualifier(
classifier: ClassifierDescriptor,
bindingContext: BindingContext
): ClassifierQualifier {
val companionObjectReceiver = (classifier as? ClassDescriptor)?.classObjectType?.let {
val companionObjectReceiver = (classifier as? ClassDescriptor)?.companionObjectType?.let {
ExpressionReceiver.create(referenceExpression, it, bindingContext)
}
return ClassifierQualifier(referenceExpression, classifier, companionObjectReceiver)
@@ -202,7 +202,7 @@ fun QualifierReceiver.resolveAsStandaloneExpression(
if (classifier is TypeParameterDescriptor) {
context.trace.report(TYPE_PARAMETER_IS_NOT_AN_EXPRESSION.on(referenceExpression, classifier))
}
else if (classifier is ClassDescriptor && !classifier.hasClassObjectType) {
else if (classifier is ClassDescriptor && !classifier.hasCompanionObject) {
context.trace.report(NO_COMPANION_OBJECT.on(referenceExpression, classifier))
}
else if (packageView != null) {
@@ -222,8 +222,8 @@ fun QualifierReceiver.resolveAsReceiverInQualifiedExpression(
if (classifier is TypeParameterDescriptor) {
context.trace.report(TYPE_PARAMETER_ON_LHS_OF_DOT.on(referenceExpression, classifier))
}
else if (classifier is ClassDescriptor && classifier.hasClassObjectType) {
context.trace.recordType(expression, classifier.classObjectType)
else if (classifier is ClassDescriptor && classifier.hasCompanionObject) {
context.trace.recordType(expression, classifier.companionObjectType)
}
}
@@ -265,7 +265,7 @@ private fun QualifierReceiver.resolveReferenceTarget(
if (declarationDescriptor is ClassifierDescriptor)
symbolUsageValidator.validateTypeUsage(declarationDescriptor, context.trace, referenceExpression)
if (isCallableWithReceiver && classifier is ClassDescriptor && classifier.hasClassObjectType) {
if (isCallableWithReceiver && classifier is ClassDescriptor && classifier.hasCompanionObject) {
val companionObjectDescriptor = classifier.getCompanionObjectDescriptor()
if (companionObjectDescriptor != null) {
context.trace.record(SHORT_REFERENCE_TO_COMPANION_OBJECT, referenceExpression, classifier)
@@ -71,10 +71,10 @@ public val ClassDescriptor.classId: ClassId
throw IllegalStateException("Illegal container: $owner")
}
public val ClassDescriptor.hasClassObjectType: Boolean get() = classObjectType != null
public val ClassDescriptor.hasCompanionObject: Boolean get() = companionObjectType != null
/** If a literal of this class can be used as a value, returns the type of this value */
public val ClassDescriptor.classObjectType: KotlinType?
public val ClassDescriptor.companionObjectType: KotlinType?
get() {
val correspondingDescriptor = when (this.getKind()) {
OBJECT -> this
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType
import org.jetbrains.kotlin.resolve.descriptorUtil.companionObjectType
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.sure
@@ -141,7 +141,7 @@ public class EnumValue(
) : ConstantValue<ClassDescriptor>(value) {
override val type: KotlinType
get() = value.classObjectType.sure { "Enum entry must have a class object type: " + value }
get() = value.companionObjectType.sure { "Enum entry must have a class object type: " + value }
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D) = visitor.visitEnumValue(this, data)