Got rid of conustructors zoo in value parameter and getter/setter descriptors.
This commit is contained in:
@@ -55,16 +55,14 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl {
|
||||
public Getter(AccessorForPropertyDescriptor property) {
|
||||
super(property, Annotations.EMPTY, Modality.FINAL, Visibilities.LOCAL,
|
||||
false,
|
||||
false, Kind.DECLARATION);
|
||||
false, Kind.DECLARATION, null);
|
||||
initialize(property.getType());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Setter extends PropertySetterDescriptorImpl {
|
||||
public Setter(AccessorForPropertyDescriptor property) {
|
||||
super(property, Annotations.EMPTY, Modality.FINAL, Visibilities.LOCAL,
|
||||
false,
|
||||
false, Kind.DECLARATION);
|
||||
super(property, Annotations.EMPTY, Modality.FINAL, Visibilities.LOCAL, false, false, Kind.DECLARATION, null);
|
||||
initializeDefault();
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -207,6 +207,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
|
||||
altParamDescriptors.add(new ValueParameterDescriptorImpl(
|
||||
originalParameterDescriptor.getContainingDeclaration(),
|
||||
null,
|
||||
originalParameterDescriptor.getIndex(),
|
||||
originalParameterDescriptor.getAnnotations(),
|
||||
altName != null ? altName : originalParameterDescriptor.getName(),
|
||||
|
||||
+1
@@ -222,6 +222,7 @@ public class SignaturesPropagationData {
|
||||
|
||||
resultParameters.add(new ValueParameterDescriptorImpl(
|
||||
originalParam.getContainingDeclaration(),
|
||||
null,
|
||||
shouldBeExtension ? originalIndex - 1 : originalIndex,
|
||||
originalParam.getAnnotations(),
|
||||
stableName != null ? stableName : originalParam.getName(),
|
||||
|
||||
+11
-10
@@ -165,11 +165,11 @@ public class DescriptorDeserializer {
|
||||
int getterFlags = proto.getGetterFlags();
|
||||
boolean isNotDefault = proto.hasGetterFlags() && Flags.IS_NOT_DEFAULT.get(getterFlags);
|
||||
if (isNotDefault) {
|
||||
getter = new PropertyGetterDescriptorImpl(
|
||||
property, getAnnotations(proto, getterFlags, AnnotatedCallableKind.PROPERTY_GETTER),
|
||||
modality(Flags.MODALITY.get(getterFlags)), visibility(Flags.VISIBILITY.get(getterFlags)),
|
||||
isNotDefault, !isNotDefault, property.getKind()
|
||||
);
|
||||
getter = new PropertyGetterDescriptorImpl(property,
|
||||
getAnnotations(proto, getterFlags, AnnotatedCallableKind.PROPERTY_GETTER),
|
||||
modality(Flags.MODALITY.get(getterFlags)),
|
||||
visibility(Flags.VISIBILITY.get(getterFlags)), isNotDefault, !isNotDefault,
|
||||
property.getKind(), null);
|
||||
}
|
||||
else {
|
||||
getter = DescriptorFactory.createDefaultGetter(property);
|
||||
@@ -181,11 +181,11 @@ public class DescriptorDeserializer {
|
||||
int setterFlags = proto.getSetterFlags();
|
||||
boolean isNotDefault = proto.hasSetterFlags() && Flags.IS_NOT_DEFAULT.get(setterFlags);
|
||||
if (isNotDefault) {
|
||||
setter = new PropertySetterDescriptorImpl(
|
||||
property, getAnnotations(proto, setterFlags, AnnotatedCallableKind.PROPERTY_SETTER),
|
||||
modality(Flags.MODALITY.get(setterFlags)), visibility(Flags.VISIBILITY.get(setterFlags)),
|
||||
isNotDefault, !isNotDefault, property.getKind()
|
||||
);
|
||||
setter = new PropertySetterDescriptorImpl(property,
|
||||
getAnnotations(proto, setterFlags, AnnotatedCallableKind.PROPERTY_SETTER),
|
||||
modality(Flags.MODALITY.get(setterFlags)),
|
||||
visibility(Flags.VISIBILITY.get(setterFlags)), isNotDefault, !isNotDefault,
|
||||
property.getKind(), null);
|
||||
DescriptorDeserializer setterLocal = local.createChildDeserializer(setter, Collections.<TypeParameter>emptyList(),
|
||||
Collections.<TypeParameterDescriptor>emptyList());
|
||||
List<ValueParameterDescriptor> valueParameters = setterLocal.valueParameters(proto, AnnotatedCallableKind.PROPERTY_SETTER);
|
||||
@@ -401,6 +401,7 @@ public class DescriptorDeserializer {
|
||||
Callable.ValueParameter proto = protos.get(i);
|
||||
result.add(new ValueParameterDescriptorImpl(
|
||||
containingDeclaration,
|
||||
null,
|
||||
i,
|
||||
getAnnotations(classOrPackage, callable, kind, proto),
|
||||
nameResolver.getName(proto.getName()),
|
||||
|
||||
@@ -423,7 +423,7 @@ public class DescriptorResolver {
|
||||
// If parameter hasn't corresponding property, so it mustn't have default value as a parameter in copy function for data class
|
||||
boolean declaresDefaultValue = propertyDescriptor != null;
|
||||
ValueParameterDescriptorImpl parameterDescriptor =
|
||||
new ValueParameterDescriptorImpl(functionDescriptor, parameter.getIndex(), parameter.getAnnotations(),
|
||||
new ValueParameterDescriptorImpl(functionDescriptor, null, parameter.getIndex(), parameter.getAnnotations(),
|
||||
parameter.getName(), parameter.getType(),
|
||||
declaresDefaultValue,
|
||||
parameter.getVarargElementType());
|
||||
@@ -546,6 +546,7 @@ public class DescriptorResolver {
|
||||
}
|
||||
ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl(
|
||||
declarationDescriptor,
|
||||
null,
|
||||
index,
|
||||
annotations,
|
||||
JetPsiUtil.safeName(valueParameter.getName()),
|
||||
@@ -1127,11 +1128,11 @@ public class DescriptorResolver {
|
||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, setter.getModifierList(), trace);
|
||||
JetParameter parameter = setter.getParameter();
|
||||
|
||||
setterDescriptor = new PropertySetterDescriptorImpl(
|
||||
propertyDescriptor, annotations,
|
||||
resolveModalityFromModifiers(setter, propertyDescriptor.getModality()),
|
||||
resolveVisibilityFromModifiers(setter, propertyDescriptor.getVisibility()),
|
||||
setter.getBodyExpression() != null, false, CallableMemberDescriptor.Kind.DECLARATION);
|
||||
setterDescriptor = new PropertySetterDescriptorImpl(propertyDescriptor, annotations,
|
||||
resolveModalityFromModifiers(setter, propertyDescriptor.getModality()),
|
||||
resolveVisibilityFromModifiers(setter, propertyDescriptor.getVisibility()),
|
||||
setter.getBodyExpression() != null, false,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null);
|
||||
if (parameter != null) {
|
||||
|
||||
// This check is redundant: the parser does not allow a default value, but we'll keep it just in case
|
||||
@@ -1204,11 +1205,11 @@ public class DescriptorResolver {
|
||||
}
|
||||
}
|
||||
|
||||
getterDescriptor = new PropertyGetterDescriptorImpl(
|
||||
propertyDescriptor, annotations,
|
||||
resolveModalityFromModifiers(getter, propertyDescriptor.getModality()),
|
||||
resolveVisibilityFromModifiers(getter, propertyDescriptor.getVisibility()),
|
||||
getter.getBodyExpression() != null, false, CallableMemberDescriptor.Kind.DECLARATION);
|
||||
getterDescriptor = new PropertyGetterDescriptorImpl(propertyDescriptor, annotations,
|
||||
resolveModalityFromModifiers(getter, propertyDescriptor.getModality()),
|
||||
resolveVisibilityFromModifiers(getter, propertyDescriptor.getVisibility()),
|
||||
getter.getBodyExpression() != null, false,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null);
|
||||
getterDescriptor.initialize(returnType);
|
||||
trace.record(BindingContext.PROPERTY_ACCESSOR, getter, getterDescriptor);
|
||||
}
|
||||
|
||||
@@ -131,6 +131,7 @@ public class FunctionDescriptorUtil {
|
||||
|
||||
parameters.add(new ValueParameterDescriptorImpl(
|
||||
descriptor,
|
||||
null,
|
||||
idx,
|
||||
parameter.getAnnotations(),
|
||||
parameter.getName(),
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ScriptHeaderResolver {
|
||||
int index,
|
||||
@NotNull ScriptDescriptor script) {
|
||||
JetType type = resolveTypeName(scriptParameter.getType());
|
||||
return new ValueParameterDescriptorImpl(script, index, Annotations.EMPTY, scriptParameter.getName(), type, false, null);
|
||||
return new ValueParameterDescriptorImpl(script, null, index, Annotations.EMPTY, scriptParameter.getName(), type, false, null);
|
||||
}
|
||||
|
||||
public void processScriptHierarchy(@NotNull TopDownAnalysisContext c, @NotNull JetScript script, @NotNull JetScope outerScope) {
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
if (functionTypeExpected && !hasDeclaredValueParameters && expectedValueParameters.size() == 1) {
|
||||
ValueParameterDescriptor valueParameterDescriptor = expectedValueParameters.get(0);
|
||||
ValueParameterDescriptor it = new ValueParameterDescriptorImpl(
|
||||
functionDescriptor, 0, Annotations.EMPTY, Name.identifier("it"),
|
||||
functionDescriptor, null, 0, Annotations.EMPTY, Name.identifier("it"),
|
||||
valueParameterDescriptor.getType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType()
|
||||
);
|
||||
valueParameterDescriptors.add(it);
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public class ControlStructureTypingUtils {
|
||||
for (int i = 0; i < argumentNames.size(); i++) {
|
||||
JetType argumentType = isArgumentNullable.get(i) ? nullableType : type;
|
||||
ValueParameterDescriptorImpl valueParameter = new ValueParameterDescriptorImpl(
|
||||
function, i, Annotations.EMPTY, Name.identifier(argumentNames.get(i)), argumentType, false, null);
|
||||
function, null, i, Annotations.EMPTY, Name.identifier(argumentNames.get(i)), argumentType, false, null);
|
||||
valueParameters.add(valueParameter);
|
||||
}
|
||||
function.initialize(
|
||||
|
||||
+1
@@ -148,6 +148,7 @@ public class LazyJavaClassMemberScope(
|
||||
|
||||
result.add(ValueParameterDescriptorImpl(
|
||||
constructor,
|
||||
null,
|
||||
index,
|
||||
Annotations.EMPTY,
|
||||
method.getName(),
|
||||
|
||||
+1
@@ -210,6 +210,7 @@ public abstract class LazyJavaMemberScope(
|
||||
|
||||
ValueParameterDescriptorImpl(
|
||||
function,
|
||||
null,
|
||||
index,
|
||||
c.resolveAnnotations(javaParameter),
|
||||
name,
|
||||
|
||||
+2
-2
@@ -147,7 +147,7 @@ public class SingleAbstractMethodUtils {
|
||||
assert parameterType != null : "couldn't substitute type: " + parameterTypeUnsubstituted +
|
||||
", substitutor = " + typeParameters.substitutor;
|
||||
ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl(
|
||||
result, 0, Annotations.EMPTY, Name.identifier("function"), parameterType, false, null);
|
||||
result, null, 0, Annotations.EMPTY, Name.identifier("function"), parameterType, false, null);
|
||||
|
||||
JetType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE);
|
||||
assert returnType != null : "couldn't substitute type: " + samInterface.getDefaultType() +
|
||||
@@ -251,7 +251,7 @@ public class SingleAbstractMethodUtils {
|
||||
assert newType != null : "couldn't substitute type: " + newTypeUnsubstituted + ", substitutor = " + typeParameters.substitutor;
|
||||
|
||||
ValueParameterDescriptor newParam = new ValueParameterDescriptorImpl(
|
||||
adapter, originalParam.getIndex(), originalParam.getAnnotations(), originalParam.getName(), newType, false, null);
|
||||
adapter, null, originalParam.getIndex(), originalParam.getAnnotations(), originalParam.getName(), newType, false, null);
|
||||
valueParameters.add(newParam);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -265,10 +265,13 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
result.add(new ValueParameterDescriptorImpl(
|
||||
substitutedDescriptor,
|
||||
unsubstitutedValueParameter,
|
||||
unsubstitutedValueParameter.getIndex(),
|
||||
unsubstitutedValueParameter.getAnnotations(),
|
||||
unsubstitutedValueParameter.getName(),
|
||||
substitutedType,
|
||||
substituteVarargElementType
|
||||
));
|
||||
unsubstitutedValueParameter.declaresDefaultValue(),
|
||||
substituteVarargElementType)
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+2
-1
@@ -62,7 +62,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind
|
||||
) {
|
||||
super(containingDeclaration, annotations, name);
|
||||
super(containingDeclaration, annotations, name, null);
|
||||
this.isVar = isVar;
|
||||
this.modality = modality;
|
||||
this.visibility = visibility;
|
||||
@@ -70,6 +70,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PropertyDescriptorImpl create(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
|
||||
-12
@@ -33,18 +33,6 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
@NotNull
|
||||
private final PropertyGetterDescriptor original;
|
||||
|
||||
public PropertyGetterDescriptorImpl(
|
||||
@NotNull PropertyDescriptor correspondingProperty,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Modality modality,
|
||||
@NotNull Visibility visibility,
|
||||
boolean hasBody,
|
||||
boolean isDefault,
|
||||
@NotNull Kind kind
|
||||
) {
|
||||
this(correspondingProperty, annotations, modality, visibility, hasBody, isDefault, kind, null);
|
||||
}
|
||||
|
||||
public PropertyGetterDescriptorImpl(
|
||||
@NotNull PropertyDescriptor correspondingProperty,
|
||||
@NotNull Annotations annotations,
|
||||
|
||||
+1
-13
@@ -35,18 +35,6 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
@NotNull
|
||||
private final PropertySetterDescriptor original;
|
||||
|
||||
public PropertySetterDescriptorImpl(
|
||||
@NotNull PropertyDescriptor correspondingProperty,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Modality modality,
|
||||
@NotNull Visibility visibility,
|
||||
boolean hasBody,
|
||||
boolean isDefault,
|
||||
@NotNull Kind kind
|
||||
) {
|
||||
this(correspondingProperty, annotations, modality, visibility, hasBody, isDefault, kind, null);
|
||||
}
|
||||
|
||||
public PropertySetterDescriptorImpl(
|
||||
@NotNull PropertyDescriptor correspondingProperty,
|
||||
@NotNull Annotations annotations,
|
||||
@@ -76,7 +64,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
@NotNull JetType type
|
||||
) {
|
||||
return new ValueParameterDescriptorImpl(
|
||||
setterDescriptor, 0, Annotations.EMPTY, Name.special("<set-?>"), type, false, null
|
||||
setterDescriptor, null, 0, Annotations.EMPTY, Name.special("<set-?>"), type, false, null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+3
-16
@@ -42,6 +42,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
|
||||
public ValueParameterDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@Nullable ValueParameterDescriptor original,
|
||||
int index,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@@ -50,26 +51,12 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
@Nullable JetType varargElementType
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, outType);
|
||||
this.original = this;
|
||||
this.original = original == null ? this : original;
|
||||
this.index = index;
|
||||
this.declaresDefaultValue = declaresDefaultValue;
|
||||
this.varargElementType = varargElementType;
|
||||
}
|
||||
|
||||
public ValueParameterDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull ValueParameterDescriptor original,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull JetType outType,
|
||||
@Nullable JetType varargElementType
|
||||
) {
|
||||
super(containingDeclaration, annotations, original.getName(), outType);
|
||||
this.original = original;
|
||||
this.index = original.getIndex();
|
||||
this.declaresDefaultValue = original.declaresDefaultValue();
|
||||
this.varargElementType = varargElementType;
|
||||
}
|
||||
|
||||
public void setType(@NotNull JetType type) {
|
||||
setOutType(type);
|
||||
}
|
||||
@@ -138,7 +125,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
||||
@NotNull
|
||||
@Override
|
||||
public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner, @NotNull Name newName) {
|
||||
return new ValueParameterDescriptorImpl(newOwner, index, getAnnotations(), newName, getType(), declaresDefaultValue(), varargElementType);
|
||||
return new ValueParameterDescriptorImpl(newOwner, null, index, getAnnotations(), newName, getType(), declaresDefaultValue(), varargElementType);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
-9
@@ -43,15 +43,6 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
this.outType = outType;
|
||||
}
|
||||
|
||||
protected VariableDescriptorImpl(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name
|
||||
)
|
||||
{
|
||||
this(containingDeclaration, annotations, name, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType() {
|
||||
|
||||
@@ -53,10 +53,10 @@ public class DescriptorFactory {
|
||||
|
||||
@NotNull
|
||||
public static PropertySetterDescriptorImpl createSetter(@NotNull PropertyDescriptor propertyDescriptor, boolean isDefault) {
|
||||
PropertySetterDescriptorImpl setterDescriptor = new PropertySetterDescriptorImpl(
|
||||
propertyDescriptor, Annotations.EMPTY, propertyDescriptor.getModality(),
|
||||
propertyDescriptor.getVisibility(),
|
||||
!isDefault, isDefault, CallableMemberDescriptor.Kind.DECLARATION);
|
||||
PropertySetterDescriptorImpl setterDescriptor =
|
||||
new PropertySetterDescriptorImpl(propertyDescriptor, Annotations.EMPTY, propertyDescriptor.getModality(),
|
||||
propertyDescriptor.getVisibility(), !isDefault, isDefault,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null);
|
||||
setterDescriptor.initializeDefault();
|
||||
return setterDescriptor;
|
||||
}
|
||||
@@ -68,10 +68,9 @@ public class DescriptorFactory {
|
||||
|
||||
@NotNull
|
||||
public static PropertyGetterDescriptorImpl createGetter(@NotNull PropertyDescriptor propertyDescriptor, boolean isDefault) {
|
||||
return new PropertyGetterDescriptorImpl(
|
||||
propertyDescriptor, Annotations.EMPTY, propertyDescriptor.getModality(),
|
||||
propertyDescriptor.getVisibility(),
|
||||
!isDefault, isDefault, CallableMemberDescriptor.Kind.DECLARATION);
|
||||
return new PropertyGetterDescriptorImpl(propertyDescriptor, Annotations.EMPTY, propertyDescriptor.getModality(),
|
||||
propertyDescriptor.getVisibility(), !isDefault, isDefault,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -107,6 +106,7 @@ public class DescriptorFactory {
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED);
|
||||
ValueParameterDescriptor parameterDescriptor = new ValueParameterDescriptorImpl(
|
||||
values,
|
||||
null,
|
||||
0,
|
||||
Annotations.EMPTY,
|
||||
Name.identifier("value"),
|
||||
|
||||
@@ -853,7 +853,7 @@ public class KotlinBuiltIns {
|
||||
for (int i = 0; i < parameterTypes.size(); i++) {
|
||||
TypeProjection parameterType = parameterTypes.get(i);
|
||||
ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl(
|
||||
functionDescriptor, i, Annotations.EMPTY,
|
||||
functionDescriptor, null, i, Annotations.EMPTY,
|
||||
Name.identifier("p" + (i + 1)), parameterType.getType(), false, null);
|
||||
valueParameters.add(valueParameterDescriptor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user