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