Introduce and implement SimpleFunctionDescriptor.createRenamedCopy

This commit is contained in:
Denis Zharkov
2015-10-23 11:22:11 +03:00
parent 69038063a6
commit ce34550c42
13 changed files with 76 additions and 28 deletions
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor;
import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor;
import org.jetbrains.kotlin.name.Name;
/* package */ class SamAdapterFunctionDescriptor extends JavaMethodDescriptor implements SamAdapterDescriptor<JavaMethodDescriptor> {
private final JavaMethodDescriptor declaration;
@@ -53,7 +54,8 @@ import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor;
protected JavaMethodDescriptor createSubstitutedCopy(
@NotNull DeclarationDescriptor newOwner,
@Nullable FunctionDescriptor original,
@NotNull Kind kind
@NotNull Kind kind,
@Nullable Name newName
) {
return new SamAdapterFunctionDescriptor(newOwner, (SimpleFunctionDescriptor) original, kind, declaration);
}
@@ -141,8 +141,15 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingSc
override fun hasStableParameterNames() = sourceFunction.hasStableParameterNames()
override fun hasSynthesizedParameterNames() = sourceFunction.hasSynthesizedParameterNames()
override fun createSubstitutedCopy(newOwner: DeclarationDescriptor, original: FunctionDescriptor?, kind: CallableMemberDescriptor.Kind): MyFunctionDescriptor {
return MyFunctionDescriptor(containingDeclaration, original as SimpleFunctionDescriptor?, annotations, name, kind, source).apply {
override fun createSubstitutedCopy(
newOwner: DeclarationDescriptor,
original: FunctionDescriptor?,
kind: CallableMemberDescriptor.Kind,
newName: Name?
): MyFunctionDescriptor {
return MyFunctionDescriptor(
containingDeclaration, original as SimpleFunctionDescriptor?, annotations, newName ?: name, kind, source
).apply {
sourceFunction = this@MyFunctionDescriptor.sourceFunction
}
}
@@ -162,13 +169,14 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingSc
kind: CallableMemberDescriptor.Kind,
newValueParameterDescriptors: MutableList<ValueParameterDescriptor>,
newExtensionReceiverParameterType: KotlinType?,
newReturnType: KotlinType
newReturnType: KotlinType,
name: Name?
): FunctionDescriptor? {
val descriptor = super<SimpleFunctionDescriptorImpl>.doSubstitute(
val descriptor = super.doSubstitute(
originalSubstitutor, newOwner, newModality, newVisibility,
newIsOperator, newIsInfix, newIsExternal, newIsInline, newIsTailrec, original,
copyOverrides, kind, newValueParameterDescriptors, newExtensionReceiverParameterType, newReturnType)
as MyFunctionDescriptor? ?: return null
copyOverrides, kind, newValueParameterDescriptors, newExtensionReceiverParameterType, newReturnType, name)
as MyFunctionDescriptor? ?: return null
if (original == null) {
throw UnsupportedOperationException("doSubstitute with no original should not be called for synthetic extension")