Extracted "preserve original" flag.
This commit is contained in:
+8
-2
@@ -23,6 +23,7 @@ import org.jetbrains.jet.descriptors.serialization.Flags;
|
|||||||
import org.jetbrains.jet.descriptors.serialization.NameResolver;
|
import org.jetbrains.jet.descriptors.serialization.NameResolver;
|
||||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
|
import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
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.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
||||||
@@ -47,11 +48,16 @@ public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescript
|
|||||||
this.nameResolver = nameResolver;
|
this.nameResolver = nameResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
|
protected FunctionDescriptorImpl createSubstitutedCopy(
|
||||||
|
@NotNull DeclarationDescriptor newOwner,
|
||||||
|
@Nullable FunctionDescriptor original,
|
||||||
|
@NotNull Kind kind
|
||||||
|
) {
|
||||||
return new DeserializedSimpleFunctionDescriptor(
|
return new DeserializedSimpleFunctionDescriptor(
|
||||||
newOwner,
|
newOwner,
|
||||||
preserveOriginal ? getOriginal() : null,
|
(DeserializedSimpleFunctionDescriptor) original,
|
||||||
getAnnotations(),
|
getAnnotations(),
|
||||||
getName(),
|
getName(),
|
||||||
kind,
|
kind,
|
||||||
|
|||||||
+7
-1
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
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.annotations.Annotations;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl;
|
||||||
|
|
||||||
@@ -54,8 +55,13 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl {
|
|||||||
this.hasStableParameterNames = hasStableParameterNames;
|
this.hasStableParameterNames = hasStableParameterNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@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) {
|
if (kind != Kind.DECLARATION) {
|
||||||
throw new IllegalStateException("Attempt at creating a constructor that is not a declaration: \n" +
|
throw new IllegalStateException("Attempt at creating a constructor that is not a declaration: \n" +
|
||||||
"copy from: " + this + "\n" +
|
"copy from: " + this + "\n" +
|
||||||
|
|||||||
+8
-2
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.resolve.java.descriptor;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
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.SimpleFunctionDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
||||||
@@ -57,11 +58,16 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
|
|||||||
this.hasStableParameterNames = hasStableParameterNames;
|
this.hasStableParameterNames = hasStableParameterNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@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(
|
JavaMethodDescriptor result = new JavaMethodDescriptor(
|
||||||
newOwner,
|
newOwner,
|
||||||
preserveOriginal ? getOriginal() : null,
|
(SimpleFunctionDescriptor) original,
|
||||||
getAnnotations(),
|
getAnnotations(),
|
||||||
getName(),
|
getName(),
|
||||||
kind
|
kind
|
||||||
|
|||||||
+7
-2
@@ -105,15 +105,20 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
|||||||
throw new UnsupportedOperationException("Constructors cannot override anything");
|
throw new UnsupportedOperationException("Constructors cannot override anything");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
|
protected FunctionDescriptorImpl createSubstitutedCopy(
|
||||||
|
@NotNull DeclarationDescriptor newOwner,
|
||||||
|
@Nullable FunctionDescriptor original,
|
||||||
|
@NotNull Kind kind
|
||||||
|
) {
|
||||||
if (kind != Kind.DECLARATION) {
|
if (kind != Kind.DECLARATION) {
|
||||||
throw new IllegalStateException("Attempt at creating a constructor that is not a declaration: \n" +
|
throw new IllegalStateException("Attempt at creating a constructor that is not a declaration: \n" +
|
||||||
"copy from: " + this + "\n" +
|
"copy from: " + this + "\n" +
|
||||||
"newOwner: " + newOwner + "\n" +
|
"newOwner: " + newOwner + "\n" +
|
||||||
"kind: " + kind);
|
"kind: " + kind);
|
||||||
}
|
}
|
||||||
assert preserveOriginal : "Attempt to create copy of constructor without preserving original: " + this;
|
assert original != null : "Attempt to create copy of constructor without preserving original: " + this;
|
||||||
return new ConstructorDescriptorImpl(
|
return new ConstructorDescriptorImpl(
|
||||||
(ClassDescriptor) newOwner,
|
(ClassDescriptor) newOwner,
|
||||||
this,
|
this,
|
||||||
|
|||||||
+17
-5
@@ -180,12 +180,19 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
if (originalSubstitutor.isEmpty()) {
|
if (originalSubstitutor.isEmpty()) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return doSubstitute(originalSubstitutor, getContainingDeclaration(), modality, visibility, true, true, getKind());
|
return doSubstitute(originalSubstitutor, getContainingDeclaration(), modality, visibility, getOriginal(), true, getKind());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected FunctionDescriptor doSubstitute(TypeSubstitutor originalSubstitutor,
|
@Nullable
|
||||||
DeclarationDescriptor newOwner, Modality newModality, Visibility newVisibility, boolean preserveOriginal, boolean copyOverrides, Kind kind) {
|
protected FunctionDescriptor doSubstitute(@NotNull TypeSubstitutor originalSubstitutor,
|
||||||
FunctionDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, preserveOriginal, kind);
|
@NotNull DeclarationDescriptor newOwner,
|
||||||
|
@NotNull Modality newModality,
|
||||||
|
@NotNull Visibility newVisibility,
|
||||||
|
@Nullable FunctionDescriptor original,
|
||||||
|
boolean copyOverrides,
|
||||||
|
@NotNull Kind kind
|
||||||
|
) {
|
||||||
|
FunctionDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, original, kind);
|
||||||
|
|
||||||
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
|
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
|
||||||
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
|
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
|
||||||
@@ -233,7 +240,12 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
|||||||
return substitutedDescriptor;
|
return substitutedDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind);
|
@NotNull
|
||||||
|
protected abstract FunctionDescriptorImpl createSubstitutedCopy(
|
||||||
|
@NotNull DeclarationDescriptor newOwner,
|
||||||
|
@Nullable FunctionDescriptor original,
|
||||||
|
@NotNull Kind kind
|
||||||
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R, D> R accept(DeclarationDescriptorVisitor<R, D> visitor, D data) {
|
public <R, D> R accept(DeclarationDescriptorVisitor<R, D> visitor, D data) {
|
||||||
|
|||||||
+13
-5
@@ -195,12 +195,20 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
|||||||
if (originalSubstitutor.isEmpty()) {
|
if (originalSubstitutor.isEmpty()) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return doSubstitute(originalSubstitutor, getContainingDeclaration(), modality, visibility, true, true, getKind());
|
return doSubstitute(originalSubstitutor, getContainingDeclaration(), modality, visibility, getOriginal(), true, getKind());
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyDescriptor doSubstitute(TypeSubstitutor originalSubstitutor,
|
@Nullable
|
||||||
DeclarationDescriptor newOwner, Modality newModality, Visibility newVisibility, boolean preserveOriginal, boolean copyOverrides, Kind kind) {
|
private PropertyDescriptor doSubstitute(
|
||||||
PropertyDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, newModality, newVisibility, preserveOriginal ? getOriginal() : null, kind);
|
@NotNull TypeSubstitutor originalSubstitutor,
|
||||||
|
@NotNull DeclarationDescriptor newOwner,
|
||||||
|
@NotNull Modality newModality,
|
||||||
|
@NotNull Visibility newVisibility,
|
||||||
|
@Nullable PropertyDescriptor original,
|
||||||
|
boolean copyOverrides,
|
||||||
|
@NotNull Kind kind
|
||||||
|
) {
|
||||||
|
PropertyDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, newModality, newVisibility, original, kind);
|
||||||
|
|
||||||
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
|
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
|
||||||
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
|
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
|
||||||
@@ -326,6 +334,6 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public PropertyDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
|
public PropertyDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
|
||||||
return doSubstitute(TypeSubstitutor.EMPTY, newOwner, modality, visibility, false, copyOverrides, kind);
|
return doSubstitute(TypeSubstitutor.EMPTY, newOwner, modality, visibility, null, copyOverrides, kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.lang.descriptors.impl;
|
package org.jetbrains.jet.lang.descriptors.impl;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
@@ -39,8 +40,13 @@ public class ScriptCodeDescriptor extends FunctionDescriptorImpl {
|
|||||||
super.initialize(null, expectedThisObject, Collections.<TypeParameterDescriptor>emptyList(), valueParameters, returnType, Modality.FINAL, Visibilities.LOCAL);
|
super.initialize(null, expectedThisObject, Collections.<TypeParameterDescriptor>emptyList(), valueParameters, returnType, Modality.FINAL, Visibilities.LOCAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
|
protected FunctionDescriptorImpl createSubstitutedCopy(
|
||||||
|
@NotNull DeclarationDescriptor newOwner,
|
||||||
|
@Nullable FunctionDescriptor original,
|
||||||
|
@NotNull Kind kind
|
||||||
|
) {
|
||||||
throw new IllegalStateException("no need to copy script code descriptor");
|
throw new IllegalStateException("no need to copy script code descriptor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-3
@@ -75,11 +75,16 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
|||||||
return (SimpleFunctionDescriptor) super.getOriginal();
|
return (SimpleFunctionDescriptor) super.getOriginal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
|
protected FunctionDescriptorImpl createSubstitutedCopy(
|
||||||
|
@NotNull DeclarationDescriptor newOwner,
|
||||||
|
@Nullable FunctionDescriptor original,
|
||||||
|
@NotNull Kind kind
|
||||||
|
) {
|
||||||
return new SimpleFunctionDescriptorImpl(
|
return new SimpleFunctionDescriptorImpl(
|
||||||
newOwner,
|
newOwner,
|
||||||
preserveOriginal ? getOriginal() : null,
|
(SimpleFunctionDescriptor) original,
|
||||||
// TODO : safeSubstitute
|
// TODO : safeSubstitute
|
||||||
getAnnotations(),
|
getAnnotations(),
|
||||||
getName(),
|
getName(),
|
||||||
@@ -89,7 +94,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
|
public SimpleFunctionDescriptor copy(DeclarationDescriptor newOwner, Modality modality, Visibility visibility, Kind kind, boolean copyOverrides) {
|
||||||
return (SimpleFunctionDescriptorImpl)doSubstitute(TypeSubstitutor.EMPTY, newOwner, modality, visibility, false, copyOverrides, kind);
|
return (SimpleFunctionDescriptorImpl)doSubstitute(TypeSubstitutor.EMPTY, newOwner, modality, visibility, null, copyOverrides, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+7
-1
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.lang.types.error;
|
package org.jetbrains.jet.lang.types.error;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
||||||
@@ -34,8 +35,13 @@ public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorI
|
|||||||
this.ownerScope = ownerScope;
|
this.ownerScope = ownerScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
|
protected FunctionDescriptorImpl createSubstitutedCopy(
|
||||||
|
@NotNull DeclarationDescriptor newOwner,
|
||||||
|
@Nullable FunctionDescriptor original,
|
||||||
|
@NotNull Kind kind
|
||||||
|
) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user