Extracted "preserve original" flag.

This commit is contained in:
Evgeny Gerashchenko
2014-03-25 19:05:55 +04:00
parent 1aaea21f63
commit 48f8aa279b
9 changed files with 82 additions and 22 deletions
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl;
@@ -54,8 +55,13 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl {
this.hasStableParameterNames = hasStableParameterNames;
}
@NotNull
@Override
protected JavaConstructorDescriptor createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
protected JavaConstructorDescriptor createSubstitutedCopy(
@NotNull DeclarationDescriptor newOwner,
@Nullable FunctionDescriptor original,
@NotNull Kind kind
) {
if (kind != Kind.DECLARATION) {
throw new IllegalStateException("Attempt at creating a constructor that is not a declaration: \n" +
"copy from: " + this + "\n" +
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.resolve.java.descriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
@@ -57,11 +58,16 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
this.hasStableParameterNames = hasStableParameterNames;
}
@NotNull
@Override
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
protected FunctionDescriptorImpl createSubstitutedCopy(
@NotNull DeclarationDescriptor newOwner,
@Nullable FunctionDescriptor original,
@NotNull Kind kind
) {
JavaMethodDescriptor result = new JavaMethodDescriptor(
newOwner,
preserveOriginal ? getOriginal() : null,
(SimpleFunctionDescriptor) original,
getAnnotations(),
getName(),
kind