Add 'preserveSource' parameter to methods making substitution copies

This commit is contained in:
Denis Zharkov
2015-10-26 10:50:59 +03:00
parent dd46056784
commit 80bf7316c7
12 changed files with 55 additions and 30 deletions
@@ -77,7 +77,8 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
@NotNull DeclarationDescriptor newOwner,
@Nullable FunctionDescriptor original,
@NotNull Kind kind,
@Nullable Name newName
@Nullable Name newName,
boolean preserveSource
) {
if (kind != Kind.DECLARATION && kind != Kind.SYNTHESIZED) {
throw new IllegalStateException(
@@ -91,7 +92,7 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
assert newName == null : "Attempt to rename constructor: " + this;
JavaConstructorDescriptor result = new JavaConstructorDescriptor(
(ClassDescriptor) newOwner, this, getAnnotations(), isPrimary, kind, SourceElement.NO_SOURCE
(ClassDescriptor) newOwner, this, getAnnotations(), isPrimary, kind, getSourceToUseForCopy(preserveSource, original)
);
result.setHasStableParameterNames(hasStableParameterNames());
result.setHasSynthesizedParameterNames(hasSynthesizedParameterNames());
@@ -105,7 +106,7 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme
@NotNull List<KotlinType> enhancedValueParametersTypes,
@NotNull KotlinType enhancedReturnType
) {
JavaConstructorDescriptor enhanced = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind(), null);
JavaConstructorDescriptor enhanced = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind(), null, false);
// We do not use doSubstitute here as in JavaMethodDescriptor.enhance because type parameters of constructor belongs to class
enhanced.initialize(
enhancedReceiverType,
@@ -114,7 +114,8 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
@NotNull DeclarationDescriptor newOwner,
@Nullable FunctionDescriptor original,
@NotNull Kind kind,
@Nullable Name newName
@Nullable Name newName,
boolean preserveSource
) {
JavaMethodDescriptor result = new JavaMethodDescriptor(
newOwner,
@@ -122,7 +123,7 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
getAnnotations(),
newName != null ? newName : getName(),
kind,
original != null ? original.getSource() : SourceElement.NO_SOURCE
getSourceToUseForCopy(preserveSource, original)
);
result.setParameterNamesStatus(hasStableParameterNames(), hasSynthesizedParameterNames());
return result;
@@ -146,7 +147,7 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
isOperator(), isInfix(), isExternal(), isInline(), isTailrec(), getOriginal(),
/* copyOverrides = */ true, getKind(),
enhancedValueParameters, enhancedReceiverType, enhancedReturnType,
null);
null, false);
assert enhancedMethod != null : "null after substitution while enhancing " + toString();
return enhancedMethod;