Drop ClassifierDescriptor#getClassObjectType()
Introduce utility for ClassDescriptor to use where necessary
This commit is contained in:
@@ -38,6 +38,8 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getClassObjectType;
|
||||
|
||||
public abstract class AnnotationCodegen {
|
||||
|
||||
public static final class JvmFlagAnnotation {
|
||||
@@ -325,7 +327,7 @@ public abstract class AnnotationCodegen {
|
||||
CompileTimeConstant<?> compileTimeConstant = valueArguments.iterator().next();
|
||||
if (compileTimeConstant instanceof EnumValue) {
|
||||
ClassDescriptor enumEntry = ((EnumValue) compileTimeConstant).getValue();
|
||||
JetType classObjectType = enumEntry.getClassObjectType();
|
||||
JetType classObjectType = getClassObjectType(enumEntry);
|
||||
if (classObjectType != null) {
|
||||
if ("java/lang/annotation/RetentionPolicy".equals(typeMapper.mapType(classObjectType).getInternalName())) {
|
||||
return RetentionPolicy.valueOf(enumEntry.getName().asString());
|
||||
|
||||
@@ -225,8 +225,6 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory1<JetNamedDeclaration, TypeParameterDescriptor> CONFLICTING_UPPER_BOUNDS =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory1<JetNamedDeclaration, TypeParameterDescriptor> CONFLICTING_COMPANION_OBJECT_UPPER_BOUNDS
|
||||
= DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
|
||||
|
||||
DiagnosticFactory2<JetSimpleNameExpression, JetTypeConstraint, JetTypeParameterListOwner> NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER =
|
||||
DiagnosticFactory2.create(ERROR);
|
||||
|
||||
-1
@@ -361,7 +361,6 @@ public class DefaultErrorMessages {
|
||||
MAP.put(DYNAMIC_UPPER_BOUND, "Dynamic type can not be used as an upper bound");
|
||||
MAP.put(USELESS_ELVIS, "Elvis operator (?:) always returns the left operand of non-nullable type {0}", RENDER_TYPE);
|
||||
MAP.put(CONFLICTING_UPPER_BOUNDS, "Upper bounds of {0} have empty intersection", NAME);
|
||||
MAP.put(CONFLICTING_COMPANION_OBJECT_UPPER_BOUNDS, "Companion object upper bounds of {0} have empty intersection", NAME);
|
||||
|
||||
MAP.put(TOO_MANY_ARGUMENTS, "Too many arguments for {0}", FQ_NAMES_IN_TYPES);
|
||||
|
||||
|
||||
@@ -59,7 +59,8 @@ import static org.jetbrains.kotlin.lexer.JetTokens.OVERRIDE_KEYWORD;
|
||||
import static org.jetbrains.kotlin.lexer.JetTokens.VARARG_KEYWORD;
|
||||
import static org.jetbrains.kotlin.resolve.BindingContext.*;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
|
||||
import static org.jetbrains.kotlin.resolve.ModifiersChecker.*;
|
||||
import static org.jetbrains.kotlin.resolve.ModifiersChecker.resolveModalityFromModifiers;
|
||||
import static org.jetbrains.kotlin.resolve.ModifiersChecker.resolveVisibilityFromModifiers;
|
||||
import static org.jetbrains.kotlin.resolve.source.SourcePackage.toSourceElement;
|
||||
|
||||
public class DescriptorResolver {
|
||||
@@ -543,11 +544,6 @@ public class DescriptorResolver {
|
||||
if (KotlinBuiltIns.isNothing(parameter.getUpperBoundsAsType())) {
|
||||
trace.report(CONFLICTING_UPPER_BOUNDS.on(typeParameter, parameter));
|
||||
}
|
||||
|
||||
JetType classObjectType = parameter.getClassObjectType();
|
||||
if (classObjectType != null && KotlinBuiltIns.isNothing(classObjectType)) {
|
||||
trace.report(CONFLICTING_COMPANION_OBJECT_UPPER_BOUNDS.on(typeParameter, parameter));
|
||||
}
|
||||
}
|
||||
|
||||
public void checkNamesInConstraints(
|
||||
|
||||
+7
-6
@@ -17,15 +17,16 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.tasks.collectors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.isStaticNestedClass
|
||||
import org.jetbrains.kotlin.resolve.LibrarySourceHacks
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassObjectType
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.isStaticNestedClass
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
|
||||
public trait CallableDescriptorCollector<D : CallableDescriptor> {
|
||||
|
||||
public fun getNonExtensionsByName(scope: JetScope, name: Name, bindingTrace: BindingTrace): Collection<D>
|
||||
@@ -102,9 +103,9 @@ private object VariableCollector : CallableDescriptorCollector<VariableDescripto
|
||||
|
||||
private fun getFakeDescriptorForObject(scope: JetScope, name: Name): VariableDescriptor? {
|
||||
val classifier = scope.getClassifier(name)
|
||||
if (classifier !is ClassDescriptor || classifier.getClassObjectType() == null) return null
|
||||
if (classifier !is ClassDescriptor || !classifier.hasClassObjectType) return null
|
||||
|
||||
return FakeCallableDescriptorForObject(classifier as ClassDescriptor)
|
||||
return FakeCallableDescriptorForObject(classifier)
|
||||
}
|
||||
|
||||
override fun getNonExtensionsByName(scope: JetScope, name: Name, bindingTrace: BindingTrace): Collection<VariableDescriptor> {
|
||||
|
||||
+7
-12
@@ -16,25 +16,20 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.util
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import java.util.Collections
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getClassObjectReferenceTarget
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassObjectType
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import java.util.Collections
|
||||
|
||||
public class FakeCallableDescriptorForObject(
|
||||
public val classDescriptor: ClassDescriptor
|
||||
) : DeclarationDescriptorWithVisibility by classDescriptor.getClassObjectReferenceTarget(), VariableDescriptor {
|
||||
|
||||
init {
|
||||
assert(classDescriptor.getClassObjectType() != null) {
|
||||
assert(classDescriptor.hasClassObjectType) {
|
||||
"FakeCallableDescriptorForObject can be created only for objects, classes with companion object or enum entries: $classDescriptor"
|
||||
}
|
||||
|
||||
@@ -58,7 +53,7 @@ public class FakeCallableDescriptorForObject(
|
||||
|
||||
override fun getOverriddenDescriptors(): Set<CallableDescriptor> = Collections.emptySet()
|
||||
|
||||
override fun getType(): JetType = classDescriptor.getClassObjectType()!!
|
||||
override fun getType(): JetType = classDescriptor.classObjectType!!
|
||||
|
||||
override fun isVar() = false
|
||||
|
||||
|
||||
-1
@@ -495,7 +495,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
getDescriptorsForExtraCompanionObjects();
|
||||
|
||||
getClassObjectType();
|
||||
getConstructors();
|
||||
getContainingDeclaration();
|
||||
getThisAsReceiverParameter();
|
||||
|
||||
+1
-2
@@ -18,13 +18,13 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext;
|
||||
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.lexer.JetTokens;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorResolver;
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyClassContext;
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyEntity;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
|
||||
@@ -119,7 +119,6 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
||||
@Override
|
||||
public void forceResolveAllContents() {
|
||||
ForceResolveUtil.forceResolveAllContents(getAnnotations());
|
||||
ForceResolveUtil.forceResolveAllContents(getClassObjectType());
|
||||
getContainingDeclaration();
|
||||
getDefaultType();
|
||||
getIndex();
|
||||
|
||||
@@ -17,23 +17,32 @@
|
||||
package org.jetbrains.kotlin.resolve.scopes.receivers
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.EXPRESSION_EXPECTED_PACKAGE_FOUND
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.NO_COMPANION_OBJECT
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.TYPE_PARAMETER_IS_NOT_AN_EXPRESSION
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.TYPE_PARAMETER_ON_LHS_OF_DOT
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.psi.JetSimpleNameExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getTopmostParentQualifiedExpressionForSelector
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.EXPRESSION_TYPE
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.QUALIFIER
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.REFERENCE_TARGET
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import java.util.ArrayList
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.*
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getTopmostParentQualifiedExpressionForSelector
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getClassObjectReferenceTarget
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.recordScopeAndDataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getClassObjectReferenceTarget
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassObjectType
|
||||
import org.jetbrains.kotlin.resolve.scopes.ChainedScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.FilteringScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.ArrayList
|
||||
import kotlin.properties.Delegates
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectDescriptor
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
|
||||
public trait Qualifier: ReceiverValue {
|
||||
|
||||
@@ -66,7 +75,7 @@ class QualifierReceiver (
|
||||
override var resultingDescriptor: DeclarationDescriptor by Delegates.notNull()
|
||||
|
||||
override val scope: JetScope get() {
|
||||
val classObjectTypeScope = classifier?.getClassObjectType()?.getMemberScope()?.let {
|
||||
val classObjectTypeScope = (classifier as? ClassDescriptor)?.classObjectType?.getMemberScope()?.let {
|
||||
FilteringScope(it) { it !is ClassDescriptor }
|
||||
}
|
||||
val scopes = listOf(classObjectTypeScope, getNestedClassesAndPackageMembersScope()).filterNotNull().copyToArray()
|
||||
@@ -74,7 +83,8 @@ class QualifierReceiver (
|
||||
}
|
||||
|
||||
fun getClassObjectReceiver(): ReceiverValue =
|
||||
classifier?.getClassObjectType()?.let { ExpressionReceiver(referenceExpression, it) } ?: ReceiverValue.NO_RECEIVER
|
||||
(classifier as? ClassDescriptor)?.classObjectType?.let { ExpressionReceiver(referenceExpression, it) }
|
||||
?: ReceiverValue.NO_RECEIVER
|
||||
|
||||
fun getNestedClassesAndPackageMembersScope(): JetScope {
|
||||
val scopes = ArrayList<JetScope>(4)
|
||||
@@ -128,7 +138,7 @@ private fun QualifierReceiver.resolveAsStandaloneExpression(context: ExpressionT
|
||||
if (classifier is TypeParameterDescriptor) {
|
||||
context.trace.report(TYPE_PARAMETER_IS_NOT_AN_EXPRESSION.on(referenceExpression, classifier))
|
||||
}
|
||||
else if (classifier is ClassDescriptor && classifier.getClassObjectType() == null) {
|
||||
else if (classifier is ClassDescriptor && !classifier.hasClassObjectType) {
|
||||
context.trace.report(NO_COMPANION_OBJECT.on(referenceExpression, classifier))
|
||||
}
|
||||
else if (packageView != null) {
|
||||
@@ -140,10 +150,10 @@ private fun QualifierReceiver.resolveAsStandaloneExpression(context: ExpressionT
|
||||
private fun QualifierReceiver.resolveAsReceiverInQualifiedExpression(context: ExpressionTypingContext, selector: DeclarationDescriptor?) {
|
||||
resolveAndRecordReferenceTarget(context, selector)
|
||||
if (classifier is TypeParameterDescriptor) {
|
||||
context.trace.report(TYPE_PARAMETER_ON_LHS_OF_DOT.on(referenceExpression, classifier as TypeParameterDescriptor))
|
||||
context.trace.report(TYPE_PARAMETER_ON_LHS_OF_DOT.on(referenceExpression, classifier))
|
||||
}
|
||||
else if (classifier is ClassDescriptor && classifier.classObjectDescriptor != null) {
|
||||
context.trace.record(EXPRESSION_TYPE, expression, classifier.getClassObjectType())
|
||||
else if (classifier is ClassDescriptor && classifier.hasClassObjectType) {
|
||||
context.trace.record(EXPRESSION_TYPE, expression, classifier.classObjectType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +183,7 @@ private fun QualifierReceiver.resolveReferenceTarget(
|
||||
val isCallableWithReceiver = selector is CallableDescriptor &&
|
||||
(selector.getDispatchReceiverParameter() != null || selector.getExtensionReceiverParameter() != null)
|
||||
|
||||
if (classifier is ClassDescriptor && classifier.classObjectDescriptor != null && isCallableWithReceiver) {
|
||||
if (classifier is ClassDescriptor && classifier.hasClassObjectType && isCallableWithReceiver) {
|
||||
if (classifier.getCompanionObjectDescriptor() != null) {
|
||||
context.trace.record(SHORT_REFERENCE_TO_COMPANION_OBJECT, referenceExpression, classifier)
|
||||
}
|
||||
|
||||
@@ -56,10 +56,6 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor,
|
||||
@Override
|
||||
ClassDescriptor substitute(@NotNull TypeSubstitutor substitutor);
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
JetType getClassObjectType();
|
||||
|
||||
/**
|
||||
* @return nested object declared as 'companion' if one is present.
|
||||
*/
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.TypeConstructor;
|
||||
|
||||
@@ -27,7 +26,4 @@ public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot {
|
||||
|
||||
@NotNull
|
||||
JetType getDefaultType();
|
||||
|
||||
@Nullable
|
||||
JetType getClassObjectType();
|
||||
}
|
||||
|
||||
-9
@@ -18,10 +18,8 @@ package org.jetbrains.kotlin.descriptors.impl;
|
||||
|
||||
import kotlin.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage;
|
||||
import org.jetbrains.kotlin.resolve.scopes.InnerClassesScopeWrapper;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.SubstitutingScope;
|
||||
@@ -75,13 +73,6 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor {
|
||||
@NotNull
|
||||
protected abstract JetScope getScopeForMemberLookup();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetType getClassObjectType() {
|
||||
ClassDescriptor classObject = DescriptorUtilPackage.getClassObjectDescriptor(this);
|
||||
return classObject == null ? null : classObject.getDefaultType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetScope getUnsubstitutedInnerClassesScope() {
|
||||
|
||||
-6
@@ -150,12 +150,6 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
return defaultType.invoke();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType getClassObjectType() {
|
||||
// TODO: companion object bounds
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<JetType> getLowerBounds() {
|
||||
|
||||
-5
@@ -163,11 +163,6 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
return new LazySubstitutingClassDescriptor(this, TypeSubstitutor.create(substitutor.getSubstitution(), getSubstitutor().getSubstitution()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType getClassObjectType() {
|
||||
return original.getClassObjectType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getCompanionObjectDescriptor() {
|
||||
return original.getCompanionObjectDescriptor();
|
||||
|
||||
@@ -16,12 +16,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.descriptorUtil
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind.ENUM_CLASS
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind.ENUM_ENTRY
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind.OBJECT
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
|
||||
public fun ClassDescriptor.getClassObjectReferenceTarget(): ClassDescriptor = getCompanionObjectDescriptor() ?: this
|
||||
|
||||
@@ -57,11 +60,14 @@ public val ClassDescriptor.classId: ClassId
|
||||
throw IllegalStateException("Illegal container: $owner")
|
||||
}
|
||||
|
||||
/** If a literal of this class can be used as a value returns the class which represents the type of this value */
|
||||
public val ClassDescriptor.classObjectDescriptor: ClassDescriptor?
|
||||
public val ClassDescriptor.hasClassObjectType: Boolean get() = classObjectType != null
|
||||
|
||||
/** If a literal of this class can be used as a value, returns the type of this value */
|
||||
public val ClassDescriptor.classObjectType: JetType?
|
||||
get() {
|
||||
return when (this.getKind()) {
|
||||
val correspondingDescriptor = when (this.getKind()) {
|
||||
OBJECT -> this
|
||||
// enum entry has the type of enum class
|
||||
ENUM_ENTRY -> {
|
||||
val container = this.getContainingDeclaration()
|
||||
assert(container is ClassDescriptor && container.getKind() == ENUM_CLASS)
|
||||
@@ -69,6 +75,7 @@ public val ClassDescriptor.classObjectDescriptor: ClassDescriptor?
|
||||
}
|
||||
else -> getCompanionObjectDescriptor()
|
||||
}
|
||||
return correspondingDescriptor?.getDefaultType()
|
||||
}
|
||||
|
||||
public val DeclarationDescriptorWithVisibility.isEffectivelyPublicApi: Boolean
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
|
||||
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getClassObjectType;
|
||||
|
||||
public class EnumValue extends CompileTimeConstant<ClassDescriptor> {
|
||||
|
||||
public EnumValue(@NotNull ClassDescriptor value, boolean usesVariableAsConstant) {
|
||||
@@ -31,8 +33,8 @@ public class EnumValue extends CompileTimeConstant<ClassDescriptor> {
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
|
||||
JetType type = value.getClassObjectType();
|
||||
assert type != null : "Enum entry should have a companion object: " + value;
|
||||
JetType type = getClassObjectType(value);
|
||||
assert type != null : "Enum entry must have a class object type: " + value;
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user