Minor, get rid of AlternativeMethodSignature in irrelevant place

This commit is contained in:
Alexander Udalov
2015-11-13 22:59:44 +03:00
parent fa34ebac4a
commit 417a27f3b1
4 changed files with 27 additions and 25 deletions
@@ -60,7 +60,7 @@ public interface ExternalSignatureResolver {
private final boolean hasStableParameterNames;
public AlternativeMethodSignature(
@Nullable KotlinType returnType,
@NotNull KotlinType returnType,
@Nullable KotlinType receiverType,
@NotNull List<ValueParameterDescriptor> valueParameters,
@NotNull List<TypeParameterDescriptor> typeParameters,
@@ -75,7 +75,7 @@ public interface ExternalSignatureResolver {
this.hasStableParameterNames = hasStableParameterNames;
}
@Nullable
@NotNull
public KotlinType getReturnType() {
return returnType;
}
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.load.java.BuiltinMethodsWithDifferentJvmName.sameAsR
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.sameAsBuiltinMethodWithErasedValueParameters
import org.jetbrains.kotlin.load.java.BuiltinSpecialProperties.getBuiltinSpecialPropertyGetterName
import org.jetbrains.kotlin.load.java.components.DescriptorResolverUtils
import org.jetbrains.kotlin.load.java.components.ExternalSignatureResolver
import org.jetbrains.kotlin.load.java.components.TypeUsage
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
@@ -421,12 +420,15 @@ public class LazyJavaClassMemberScope(
override fun resolveMethodSignature(
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: KotlinType,
valueParameters: LazyJavaScope.ResolvedValueParameters
valueParameters: List<ValueParameterDescriptor>
): LazyJavaScope.MethodSignatureData {
val propagated = c.components.externalSignatureResolver.resolvePropagatedSignature(
method, ownerDescriptor, returnType, null, valueParameters.descriptors, methodTypeParameters
method, ownerDescriptor, returnType, null, valueParameters, methodTypeParameters
)
return LazyJavaScope.MethodSignatureData(
propagated.returnType, propagated.receiverType, propagated.valueParameters, propagated.typeParameters,
propagated.hasStableParameterNames(), propagated.errors
)
return LazyJavaScope.MethodSignatureData(propagated, propagated.errors)
}
private fun hasOverriddenBuiltinFunctionWithErasedValueParameters(
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.incremental.components.LookupLocation
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.incremental.record
import org.jetbrains.kotlin.load.java.components.ExternalSignatureResolver
import org.jetbrains.kotlin.load.java.components.TypeUsage
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor
@@ -97,7 +96,11 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) :
open protected fun JavaMethodDescriptor.isVisibleAsFunction() = true
protected data class MethodSignatureData(
val effectiveSignature: ExternalSignatureResolver.AlternativeMethodSignature,
val returnType: KotlinType,
val receiverType: KotlinType?,
val valueParameters: List<ValueParameterDescriptor>,
val typeParameters: List<TypeParameterDescriptor>,
val hasStableParameterNames: Boolean,
val errors: List<String>
)
@@ -105,7 +108,8 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) :
method: JavaMethod,
methodTypeParameters: List<TypeParameterDescriptor>,
returnType: KotlinType,
valueParameters: ResolvedValueParameters): MethodSignatureData
valueParameters: List<ValueParameterDescriptor>
): MethodSignatureData
fun resolveMethodToFunctionDescriptor(method: JavaMethod): JavaMethodDescriptor {
val annotations = c.resolveAnnotations(method)
@@ -120,22 +124,22 @@ public abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) :
val returnType = computeMethodReturnType(method, annotations, c)
val (effectiveSignature, signatureErrors) = resolveMethodSignature(method, methodTypeParameters, returnType, valueParameters)
val effectiveSignature = resolveMethodSignature(method, methodTypeParameters, returnType, valueParameters.descriptors)
functionDescriptorImpl.initialize(
effectiveSignature.getReceiverType(),
effectiveSignature.receiverType,
getDispatchReceiverParameter(),
effectiveSignature.getTypeParameters(),
effectiveSignature.getValueParameters(),
effectiveSignature.getReturnType(),
effectiveSignature.typeParameters,
effectiveSignature.valueParameters,
effectiveSignature.returnType,
Modality.convertFromFlags(method.isAbstract(), !method.isFinal()),
method.getVisibility()
)
functionDescriptorImpl.setParameterNamesStatus(effectiveSignature.hasStableParameterNames(), valueParameters.hasSynthesizedNames)
functionDescriptorImpl.setParameterNamesStatus(effectiveSignature.hasStableParameterNames, valueParameters.hasSynthesizedNames)
if (signatureErrors.isNotEmpty()) {
c.components.externalSignatureResolver.reportSignatureErrors(functionDescriptorImpl, signatureErrors)
if (effectiveSignature.errors.isNotEmpty()) {
c.components.externalSignatureResolver.reportSignatureErrors(functionDescriptorImpl, effectiveSignature.errors)
}
return functionDescriptorImpl
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.load.java.components.ExternalSignatureResolver
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
import org.jetbrains.kotlin.load.java.structure.JavaMethod
import org.jetbrains.kotlin.name.FqName
@@ -31,17 +31,13 @@ public abstract class LazyJavaStaticScope(c: LazyJavaResolverContext) : LazyJava
// Package fragments are not nested
override fun getPackage(name: Name) = null
abstract fun getSubPackages(): Collection<FqName>
override fun resolveMethodSignature(
method: JavaMethod, methodTypeParameters: List<TypeParameterDescriptor>, returnType: KotlinType,
valueParameters: LazyJavaScope.ResolvedValueParameters
): LazyJavaScope.MethodSignatureData {
val effectiveSignature = ExternalSignatureResolver.AlternativeMethodSignature(
returnType, null, valueParameters.descriptors, methodTypeParameters, emptyList<String>(), false
)
return LazyJavaScope.MethodSignatureData(effectiveSignature, effectiveSignature.getErrors())
}
valueParameters: List<ValueParameterDescriptor>
) = LazyJavaScope.MethodSignatureData(returnType, null, valueParameters, methodTypeParameters, false, emptyList())
override fun computeNonDeclaredProperties(name: Name, result: MutableCollection<PropertyDescriptor>) {
//no undeclared properties