Add modifier flags to descriptors
This commit is contained in:
+2
-1
@@ -141,7 +141,8 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
||||
// 1. creates full copy of descriptor
|
||||
// 2. copies method's type parameters (with new containing declaration) and properly substitute to them in value parameters, return type and etc.
|
||||
JavaMethodDescriptor enhancedMethod = (JavaMethodDescriptor) doSubstitute(
|
||||
TypeSubstitutor.EMPTY, getContainingDeclaration(), getModality(), getVisibility(), isOperator(), isInfix(), getOriginal(),
|
||||
TypeSubstitutor.EMPTY, getContainingDeclaration(), getModality(), getVisibility(),
|
||||
isOperator(), isInfix(), isExternal(), isInline(), isTailrec(), getOriginal(),
|
||||
/* copyOverrides = */ true, getKind(),
|
||||
enhancedValueParameters, enhancedReceiverType, enhancedReturnType
|
||||
);
|
||||
|
||||
+2
-2
@@ -76,7 +76,7 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
if (getter != null) {
|
||||
newGetter = new PropertyGetterDescriptorImpl(
|
||||
enhanced, getter.getAnnotations(), getter.getModality(), getter.getVisibility(),
|
||||
getter.hasBody(), getter.isDefault(), getKind(), getter, SourceElement.NO_SOURCE);
|
||||
getter.hasBody(), getter.isDefault(), getter.isExternal(), getKind(), getter, SourceElement.NO_SOURCE);
|
||||
newGetter.initialize(enhancedReturnType);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
if (setter != null) {
|
||||
newSetter = new PropertySetterDescriptorImpl(
|
||||
enhanced, setter.getAnnotations(), setter.getModality(), setter.getVisibility(),
|
||||
setter.hasBody(), setter.isDefault(), getKind(), setter, SourceElement.NO_SOURCE);
|
||||
setter.hasBody(), setter.isDefault(), setter.isExternal(), getKind(), setter, SourceElement.NO_SOURCE);
|
||||
newSetter.initialize(setter.getValueParameters().get(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ fun copyValueParameters(
|
||||
oldParameter.getName(),
|
||||
newType,
|
||||
oldParameter.declaresDefaultValue(),
|
||||
oldParameter.isCrossinline,
|
||||
oldParameter.isNoinline,
|
||||
if (oldParameter.getVarargElementType() != null) newOwner.module.builtIns.getArrayElementType(newType) else null,
|
||||
oldParameter.getSource()
|
||||
)
|
||||
|
||||
+10
-3
@@ -41,7 +41,10 @@ import org.jetbrains.kotlin.load.java.lazy.resolveAnnotations
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.RawSubstitution
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.toAttributes
|
||||
import org.jetbrains.kotlin.load.java.sources.JavaSourceElement
|
||||
import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaArrayType
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaConstructor
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.load.java.typeEnhacement.enhanceSignatures
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||
@@ -302,13 +305,15 @@ public class LazyJavaClassMemberScope(
|
||||
propertyDescriptor.setType(getterMethod.returnType!!, listOf(), getDispatchReceiverParameter(), null as JetType?)
|
||||
|
||||
val getter = DescriptorFactory.createGetter(
|
||||
propertyDescriptor, getterMethod.annotations, /* isDefault = */false, getterMethod.source
|
||||
propertyDescriptor, getterMethod.annotations, /* isDefault = */false,
|
||||
/* isExternal = */ false, getterMethod.source
|
||||
).apply {
|
||||
initialize(propertyDescriptor.type)
|
||||
}
|
||||
|
||||
val setter = setterMethod?.let { setterMethod ->
|
||||
DescriptorFactory.createSetter(propertyDescriptor, setterMethod.annotations, /* isDefault = */false, setterMethod.visibility)
|
||||
DescriptorFactory.createSetter(propertyDescriptor, setterMethod.annotations, /* isDefault = */false,
|
||||
/* isExternal = */ false, setterMethod.visibility)
|
||||
}
|
||||
|
||||
return propertyDescriptor.apply { initialize(getter, setter) }
|
||||
@@ -517,6 +522,8 @@ public class LazyJavaClassMemberScope(
|
||||
// Parameters of annotation constructors in Java are never nullable
|
||||
TypeUtils.makeNotNullable(returnType),
|
||||
method.hasAnnotationParameterDefaultValue(),
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
// Nulls are not allowed in annotation arguments in Java
|
||||
varargElementType?.let { TypeUtils.makeNotNullable(it) },
|
||||
c.components.sourceElementFactory.source(method)
|
||||
|
||||
+3
-1
@@ -207,7 +207,9 @@ public abstract class LazyJavaScope(
|
||||
annotations,
|
||||
name,
|
||||
outType,
|
||||
false,
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
varargElementType,
|
||||
c.components.sourceElementFactory.source(javaParameter)
|
||||
)
|
||||
|
||||
@@ -849,7 +849,11 @@ public abstract class KotlinBuiltIns {
|
||||
TypeProjection parameterType = parameterTypes.get(i);
|
||||
ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl(
|
||||
functionDescriptor, null, i, Annotations.Companion.getEMPTY(),
|
||||
Name.identifier("p" + (i + 1)), parameterType.getType(), false, null, SourceElement.NO_SOURCE
|
||||
Name.identifier("p" + (i + 1)), parameterType.getType(),
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
null, SourceElement.NO_SOURCE
|
||||
);
|
||||
valueParameters.add(valueParameterDescriptor);
|
||||
}
|
||||
|
||||
+8
@@ -46,6 +46,12 @@ public class FunctionInvokeDescriptor private constructor(
|
||||
return FunctionInvokeDescriptor(newOwner, original as FunctionInvokeDescriptor?, kind)
|
||||
}
|
||||
|
||||
override fun isExternal(): Boolean = false
|
||||
|
||||
override fun isInline(): Boolean = false
|
||||
|
||||
override fun isTailrec(): Boolean = false
|
||||
|
||||
companion object Factory {
|
||||
fun create(functionClass: FunctionClassDescriptor): FunctionInvokeDescriptor {
|
||||
val typeParameters = functionClass.getTypeConstructor().getParameters()
|
||||
@@ -87,6 +93,8 @@ public class FunctionInvokeDescriptor private constructor(
|
||||
Name.identifier(name),
|
||||
typeParameter.getDefaultType(),
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* varargElementType = */ null,
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
+63
-2
@@ -44,6 +44,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
private Visibility visibility = Visibilities.UNKNOWN;
|
||||
private boolean isOperator = false;
|
||||
private boolean isInfix = false;
|
||||
private boolean isExternal = false;
|
||||
private boolean isInline = false;
|
||||
private boolean isTailrec = false;
|
||||
private final Set<FunctionDescriptor> overriddenFunctions = SmartSet.create();
|
||||
private final FunctionDescriptor original;
|
||||
private final Kind kind;
|
||||
@@ -110,6 +113,18 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
this.isInfix = isInfix;
|
||||
}
|
||||
|
||||
public void setExternal(boolean isExternal) {
|
||||
this.isExternal = isExternal;
|
||||
}
|
||||
|
||||
public void setInline(boolean isInline) {
|
||||
this.isInline = isInline;
|
||||
}
|
||||
|
||||
public void setTailrec(boolean isTailrec) {
|
||||
this.isTailrec = isTailrec;
|
||||
}
|
||||
|
||||
public void setReturnType(@NotNull JetType unsubstitutedReturnType) {
|
||||
if (this.unsubstitutedReturnType != null) {
|
||||
// TODO: uncomment and fix tests
|
||||
@@ -170,6 +185,39 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternal() {
|
||||
if (isExternal) return true;
|
||||
|
||||
for (FunctionDescriptor descriptor : overriddenFunctions) {
|
||||
if (descriptor.isExternal()) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
if (isInline) return true;
|
||||
|
||||
for (FunctionDescriptor descriptor : overriddenFunctions) {
|
||||
if (descriptor.isInline()) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTailrec() {
|
||||
if (isTailrec) return true;
|
||||
|
||||
for (FunctionDescriptor descriptor : overriddenFunctions) {
|
||||
if (descriptor.isTailrec()) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOverriddenDescriptor(@NotNull CallableMemberDescriptor overriddenFunction) {
|
||||
overriddenFunctions.add((FunctionDescriptor) overriddenFunction);
|
||||
@@ -219,7 +267,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
if (originalSubstitutor.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
return doSubstitute(originalSubstitutor, getContainingDeclaration(), modality, visibility, isOperator, isInfix, getOriginal(), true, getKind());
|
||||
return doSubstitute(originalSubstitutor, getContainingDeclaration(), modality, visibility,
|
||||
isOperator, isInfix, isExternal, isInline, isTailrec,
|
||||
getOriginal(), true, getKind());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -229,12 +279,15 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
@NotNull Visibility newVisibility,
|
||||
boolean isOperator,
|
||||
boolean isInfix,
|
||||
boolean isExternal,
|
||||
boolean isInline,
|
||||
boolean isTailrec,
|
||||
@Nullable FunctionDescriptor original,
|
||||
boolean copyOverrides,
|
||||
@NotNull Kind kind
|
||||
) {
|
||||
return doSubstitute(originalSubstitutor,
|
||||
newOwner, newModality, newVisibility, isOperator, isInfix, original, copyOverrides, kind,
|
||||
newOwner, newModality, newVisibility, isOperator, isInfix, isExternal, isInline, isTailrec, original, copyOverrides, kind,
|
||||
getValueParameters(), getExtensionReceiverParameterType(), getReturnType()
|
||||
);
|
||||
}
|
||||
@@ -253,6 +306,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
@NotNull Visibility newVisibility,
|
||||
boolean isOperator,
|
||||
boolean isInfix,
|
||||
boolean isExternal,
|
||||
boolean isInline,
|
||||
boolean isTailrec,
|
||||
@Nullable FunctionDescriptor original,
|
||||
boolean copyOverrides,
|
||||
@NotNull Kind kind,
|
||||
@@ -317,6 +373,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
);
|
||||
substitutedDescriptor.setOperator(isOperator);
|
||||
substitutedDescriptor.setInfix(isInfix);
|
||||
substitutedDescriptor.setExternal(isExternal);
|
||||
substitutedDescriptor.setInline(isInline);
|
||||
substitutedDescriptor.setTailrec(isTailrec);
|
||||
|
||||
if (copyOverrides) {
|
||||
for (FunctionDescriptor overriddenFunction : overriddenFunctions) {
|
||||
@@ -362,6 +421,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
unsubstitutedValueParameter.getName(),
|
||||
substitutedType,
|
||||
unsubstitutedValueParameter.declaresDefaultValue(),
|
||||
unsubstitutedValueParameter.isCrossinline(),
|
||||
unsubstitutedValueParameter.isNoinline(),
|
||||
substituteVarargElementType,
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
+18
@@ -32,6 +32,7 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
|
||||
private final boolean hasBody;
|
||||
private final boolean isDefault;
|
||||
private final boolean isExternal;
|
||||
private final Modality modality;
|
||||
private final PropertyDescriptor correspondingProperty;
|
||||
private final Kind kind;
|
||||
@@ -45,6 +46,7 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
@NotNull Name name,
|
||||
boolean hasBody,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
@@ -54,6 +56,7 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
this.correspondingProperty = correspondingProperty;
|
||||
this.hasBody = hasBody;
|
||||
this.isDefault = isDefault;
|
||||
this.isExternal = isExternal;
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
@@ -83,6 +86,21 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternal() {
|
||||
return isExternal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTailrec() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FunctionDescriptor substitute(@NotNull TypeSubstitutor substitutor) {
|
||||
|
||||
+2
-2
@@ -257,7 +257,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
|
||||
PropertyGetterDescriptorImpl newGetter = getter == null ? null : new PropertyGetterDescriptorImpl(
|
||||
substitutedDescriptor, getter.getAnnotations(), newModality, convertVisibility(getter.getVisibility(), newVisibility),
|
||||
getter.hasBody(), getter.isDefault(), kind, original == null ? null : original.getGetter(), SourceElement.NO_SOURCE
|
||||
getter.hasBody(), getter.isDefault(), getter.isExternal(), kind, original == null ? null : original.getGetter(), SourceElement.NO_SOURCE
|
||||
);
|
||||
if (newGetter != null) {
|
||||
JetType returnType = getter.getReturnType();
|
||||
@@ -265,7 +265,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
}
|
||||
PropertySetterDescriptorImpl newSetter = setter == null ? null : new PropertySetterDescriptorImpl(
|
||||
substitutedDescriptor, setter.getAnnotations(), newModality, convertVisibility(setter.getVisibility(), newVisibility),
|
||||
setter.hasBody(), setter.isDefault(), kind, original == null ? null : original.getSetter(), SourceElement.NO_SOURCE
|
||||
setter.hasBody(), setter.isDefault(), setter.isExternal(), kind, original == null ? null : original.getSetter(), SourceElement.NO_SOURCE
|
||||
);
|
||||
if (newSetter != null) {
|
||||
List<ValueParameterDescriptor> substitutedValueParameters = FunctionDescriptorImpl.getSubstitutedValueParameters(
|
||||
|
||||
+2
-1
@@ -40,13 +40,14 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
@NotNull Visibility visibility,
|
||||
boolean hasBody,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
@NotNull Kind kind,
|
||||
@Nullable PropertyGetterDescriptor original,
|
||||
@NotNull SourceElement source
|
||||
)
|
||||
{
|
||||
super(modality, visibility, correspondingProperty, annotations, Name.special("<get-" + correspondingProperty.getName() + ">"),
|
||||
hasBody, isDefault, kind, source);
|
||||
hasBody, isDefault, isExternal, kind, source);
|
||||
this.original = original != null ? original : this;
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -42,12 +42,13 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
@NotNull Visibility visibility,
|
||||
boolean hasBody,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
@NotNull Kind kind,
|
||||
@Nullable PropertySetterDescriptor original,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(modality, visibility, correspondingProperty, annotations, Name.special("<set-" + correspondingProperty.getName() + ">"),
|
||||
hasBody, isDefault, kind, source);
|
||||
hasBody, isDefault, isExternal, kind, source);
|
||||
this.original = original != null ? original : this;
|
||||
}
|
||||
|
||||
@@ -66,7 +67,11 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
@NotNull JetType type
|
||||
) {
|
||||
return new ValueParameterDescriptorImpl(
|
||||
setterDescriptor, null, 0, Annotations.Companion.getEMPTY(), Name.special("<set-?>"), type, false, null, SourceElement.NO_SOURCE
|
||||
setterDescriptor, null, 0, Annotations.Companion.getEMPTY(), Name.special("<set-?>"), type,
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
null, SourceElement.NO_SOURCE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,4 +55,19 @@ public class ScriptCodeDescriptor extends FunctionDescriptorImpl {
|
||||
public FunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
|
||||
throw new IllegalStateException("no need to copy script code descriptor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExternal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTailrec() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -99,7 +99,9 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
boolean copyOverrides
|
||||
) {
|
||||
return (SimpleFunctionDescriptorImpl) doSubstitute(
|
||||
TypeSubstitutor.EMPTY, newOwner, modality, visibility, isOperator(), isInfix(), null, copyOverrides, kind
|
||||
TypeSubstitutor.EMPTY, newOwner, modality, visibility,
|
||||
isOperator(), isInfix(), isExternal(), isInline(), isTailrec(),
|
||||
null, copyOverrides, kind
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+22
-2
@@ -31,6 +31,8 @@ import java.util.Collection;
|
||||
|
||||
public class ValueParameterDescriptorImpl extends VariableDescriptorImpl implements ValueParameterDescriptor {
|
||||
private final boolean declaresDefaultValue;
|
||||
private final boolean isCrossinline;
|
||||
private final boolean isNoinline;
|
||||
private final JetType varargElementType;
|
||||
private final int index;
|
||||
private final ValueParameterDescriptor original;
|
||||
@@ -43,6 +45,8 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
@NotNull Name name,
|
||||
@NotNull JetType outType,
|
||||
boolean declaresDefaultValue,
|
||||
boolean isCrossinline,
|
||||
boolean isNoinline,
|
||||
@Nullable JetType varargElementType,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
@@ -50,6 +54,8 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
this.original = original == null ? this : original;
|
||||
this.index = index;
|
||||
this.declaresDefaultValue = declaresDefaultValue;
|
||||
this.isCrossinline = isCrossinline;
|
||||
this.isNoinline = isNoinline;
|
||||
this.varargElementType = varargElementType;
|
||||
}
|
||||
|
||||
@@ -66,7 +72,17 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
|
||||
@Override
|
||||
public boolean declaresDefaultValue() {
|
||||
return declaresDefaultValue && ((CallableMemberDescriptor) getContainingDeclaration()).getKind().isReal();
|
||||
return declaresDefaultValue && containingDeclarationIsReal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCrossinline() {
|
||||
return isCrossinline && containingDeclarationIsReal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNoinline() {
|
||||
return isNoinline && containingDeclarationIsReal();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -108,7 +124,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
@Override
|
||||
public ValueParameterDescriptor copy(@NotNull CallableDescriptor newOwner, @NotNull Name newName) {
|
||||
return new ValueParameterDescriptorImpl(
|
||||
newOwner, null, index, getAnnotations(), newName, getType(), declaresDefaultValue(), varargElementType,
|
||||
newOwner, null, index, getAnnotations(), newName, getType(), declaresDefaultValue(), isCrossinline(), isNoinline(), varargElementType,
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
}
|
||||
@@ -131,4 +147,8 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean containingDeclarationIsReal() {
|
||||
return ((CallableMemberDescriptor) getContainingDeclaration()).getKind().isReal();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,16 +50,7 @@ public class DescriptorFactory {
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations
|
||||
) {
|
||||
return createSetter(propertyDescriptor, annotations, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PropertySetterDescriptorImpl createSetter(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault
|
||||
) {
|
||||
return createSetter(propertyDescriptor, annotations, isDefault, propertyDescriptor.getVisibility());
|
||||
return createSetter(propertyDescriptor, annotations, true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -67,11 +58,22 @@ public class DescriptorFactory {
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault,
|
||||
boolean isExternal
|
||||
) {
|
||||
return createSetter(propertyDescriptor, annotations, isDefault, isExternal, propertyDescriptor.getVisibility());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PropertySetterDescriptorImpl createSetter(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
PropertySetterDescriptorImpl setterDescriptor =
|
||||
new PropertySetterDescriptorImpl(propertyDescriptor, annotations, propertyDescriptor.getModality(),
|
||||
visibility, !isDefault, isDefault,
|
||||
visibility, !isDefault, isDefault, isExternal,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null, propertyDescriptor.getSource());
|
||||
setterDescriptor.initializeDefault();
|
||||
return setterDescriptor;
|
||||
@@ -82,15 +84,7 @@ public class DescriptorFactory {
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations
|
||||
) {
|
||||
return createGetter(propertyDescriptor, annotations, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PropertyGetterDescriptorImpl createGetter(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault) {
|
||||
return createGetter(propertyDescriptor, annotations, isDefault, propertyDescriptor.getSource());
|
||||
return createGetter(propertyDescriptor, annotations, true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -98,9 +92,20 @@ public class DescriptorFactory {
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault,
|
||||
boolean isExternal
|
||||
) {
|
||||
return createGetter(propertyDescriptor, annotations, isDefault, isExternal, propertyDescriptor.getSource());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PropertyGetterDescriptorImpl createGetter(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
@NotNull SourceElement sourceElement) {
|
||||
return new PropertyGetterDescriptorImpl(propertyDescriptor, annotations, propertyDescriptor.getModality(),
|
||||
propertyDescriptor.getVisibility(), !isDefault, isDefault,
|
||||
propertyDescriptor.getVisibility(), !isDefault, isDefault, isExternal,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null, sourceElement);
|
||||
}
|
||||
|
||||
@@ -153,7 +158,11 @@ public class DescriptorFactory {
|
||||
SimpleFunctionDescriptorImpl.create(enumClass, Annotations.Companion.getEMPTY(), DescriptorUtils.ENUM_VALUE_OF,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, enumClass.getSource());
|
||||
ValueParameterDescriptor parameterDescriptor = new ValueParameterDescriptorImpl(
|
||||
valueOf, null, 0, Annotations.Companion.getEMPTY(), Name.identifier("value"), getBuiltIns(enumClass).getStringType(), false, null,
|
||||
valueOf, null, 0, Annotations.Companion.getEMPTY(), Name.identifier("value"), getBuiltIns(enumClass).getStringType(),
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
null,
|
||||
enumClass.getSource()
|
||||
);
|
||||
return valueOf.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
|
||||
+9
@@ -67,6 +67,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
val getter = if (hasGetter) {
|
||||
val getterFlags = proto.getGetterFlags()
|
||||
val isNotDefault = proto.hasGetterFlags() && Flags.IS_NOT_DEFAULT.get(getterFlags)
|
||||
val isExternal = proto.hasGetterFlags() && Flags.IS_EXTERNAL_ACCESSOR.get(getterFlags)
|
||||
val getter = if (isNotDefault) {
|
||||
PropertyGetterDescriptorImpl(
|
||||
property,
|
||||
@@ -75,6 +76,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
Deserialization.visibility(Flags.VISIBILITY.get(getterFlags)),
|
||||
/* hasBody = */ isNotDefault,
|
||||
/* isDefault = */ !isNotDefault,
|
||||
/* isExternal = */ isExternal,
|
||||
property.getKind(), null, SourceElement.NO_SOURCE
|
||||
)
|
||||
}
|
||||
@@ -91,6 +93,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
val setter = if (Flags.HAS_SETTER.get(flags)) {
|
||||
val setterFlags = proto.getSetterFlags()
|
||||
val isNotDefault = proto.hasSetterFlags() && Flags.IS_NOT_DEFAULT.get(setterFlags)
|
||||
val isExternal = proto.hasSetterFlags() && Flags.IS_EXTERNAL_ACCESSOR.get(setterFlags)
|
||||
if (isNotDefault) {
|
||||
val setter = PropertySetterDescriptorImpl(
|
||||
property,
|
||||
@@ -99,6 +102,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
Deserialization.visibility(Flags.VISIBILITY.get(setterFlags)),
|
||||
/* hasBody = */ isNotDefault,
|
||||
/* isDefault = */ !isNotDefault,
|
||||
/* isExternal = */ isExternal,
|
||||
property.getKind(), null, SourceElement.NO_SOURCE
|
||||
)
|
||||
val setterLocal = local.childContext(setter, listOf())
|
||||
@@ -148,6 +152,9 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
)
|
||||
function.isOperator = Flags.IS_OPERATOR.get(proto.flags)
|
||||
function.isInfix = Flags.IS_INFIX.get(proto.flags)
|
||||
function.isExternal = Flags.IS_EXTERNAL_FUNCTION.get(proto.flags)
|
||||
function.isInline = Flags.IS_INLINE.get(proto.flags)
|
||||
function.isTailrec = Flags.IS_TAILREC.get(proto.flags)
|
||||
return function
|
||||
}
|
||||
|
||||
@@ -212,6 +219,8 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
c.nameResolver.getName(proto.name),
|
||||
c.typeDeserializer.type(proto.type(c.typeTable)),
|
||||
Flags.DECLARES_DEFAULT_VALUE.get(flags),
|
||||
Flags.IS_CROSSINLINE.get(flags),
|
||||
Flags.IS_NOINLINE.get(flags),
|
||||
proto.varargElementType(c.typeTable)?.let { c.typeDeserializer.type(it) },
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
+6
@@ -45,4 +45,10 @@ public class DeserializedConstructorDescriptor(
|
||||
annotations, isPrimary, kind, proto, nameResolver, typeTable
|
||||
)
|
||||
}
|
||||
|
||||
override fun isExternal(): Boolean = false
|
||||
|
||||
override fun isInline(): Boolean = false
|
||||
|
||||
override fun isTailrec(): Boolean = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user