Support hasStableParameterNames in KotlinSignature and propagation

#KT-1924 In Progress
 #KT-2830 Fixed
This commit is contained in:
Alexander Udalov
2014-03-19 05:54:00 +04:00
parent 7fcd42f40c
commit 5fa1774cc1
90 changed files with 369 additions and 186 deletions
@@ -25,6 +25,8 @@ import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.jet.lang.resolve.name.Name;
public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implements JavaCallableMemberDescriptor {
private Boolean hasStableParameterNames = null;
public JavaMethodDescriptor(
@NotNull DeclarationDescriptor containingDeclaration,
@NotNull Annotations annotations,
@@ -54,17 +56,20 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement
@Override
public boolean hasStableParameterNames() {
// TODO: propagated names should be stable
return false;
assert hasStableParameterNames != null : "hasStableParameterNames was not set: " + this;
return hasStableParameterNames;
}
public void setHasStableParameterNames(boolean hasStableParameterNames) {
this.hasStableParameterNames = hasStableParameterNames;
}
@Override
protected FunctionDescriptorImpl createSubstitutedCopy(DeclarationDescriptor newOwner, boolean preserveOriginal, Kind kind) {
if (preserveOriginal) {
return new JavaMethodDescriptor(newOwner, getOriginal(), getAnnotations(), getName(), kind);
}
else {
return new JavaMethodDescriptor(newOwner, getAnnotations(), getName(), kind);
}
JavaMethodDescriptor result = preserveOriginal
? new JavaMethodDescriptor(newOwner, getOriginal(), getAnnotations(), getName(), kind)
: new JavaMethodDescriptor(newOwner, getAnnotations(), getName(), kind);
result.setHasStableParameterNames(hasStableParameterNames());
return result;
}
}
@@ -77,7 +77,7 @@ public class LazyJavaClassMemberScope(
val valueParameters = resolveValueParameters(c, constructorDescriptor, constructor.getValueParameters())
val effectiveSignature = c.externalSignatureResolver.resolveAlternativeMethodSignature(
constructor, false, null, null, valueParameters, Collections.emptyList())
constructor, false, null, null, valueParameters, Collections.emptyList(), false)
constructorDescriptor.initialize(
classDescriptor.getTypeConstructor().getParameters(),
@@ -126,7 +126,8 @@ public abstract class LazyJavaMemberScope(
val effectiveSignature: ExternalSignatureResolver.AlternativeMethodSignature
if (_containingDeclaration is PackageFragmentDescriptor) {
superFunctions = Collections.emptyList()
effectiveSignature = c.externalSignatureResolver.resolveAlternativeMethodSignature(method, false, returnType, null, valueParameters, methodTypeParameters)
effectiveSignature = c.externalSignatureResolver.resolveAlternativeMethodSignature(method, false, returnType, null, valueParameters,
methodTypeParameters, false)
signatureErrors = effectiveSignature.getErrors()
}
else if (_containingDeclaration is ClassDescriptor) {
@@ -134,7 +135,8 @@ public abstract class LazyJavaMemberScope(
superFunctions = propagated.getSuperMethods()
effectiveSignature = c.externalSignatureResolver.resolveAlternativeMethodSignature(
method, !superFunctions.isEmpty(), propagated.getReturnType(),
propagated.getReceiverType(), propagated.getValueParameters(), propagated.getTypeParameters())
propagated.getReceiverType(), propagated.getValueParameters(), propagated.getTypeParameters(),
propagated.hasStableParameterNames())
signatureErrors = ArrayList<String>(propagated.getErrors())
signatureErrors.addAll(effectiveSignature.getErrors())
@@ -153,6 +155,8 @@ public abstract class LazyJavaMemberScope(
method.getVisibility()
)
functionDescriptorImpl.setHasStableParameterNames(effectiveSignature.hasStableParameterNames())
if (record) {
c.javaResolverCache.recordMethod(method, functionDescriptorImpl)
}
@@ -45,19 +45,22 @@ public interface ExternalSignatureResolver {
private final JetType receiverType;
private final List<ValueParameterDescriptor> valueParameters;
private final List<TypeParameterDescriptor> typeParameters;
private final boolean hasStableParameterNames;
public AlternativeMethodSignature(
@Nullable JetType returnType,
@Nullable JetType receiverType,
@NotNull List<ValueParameterDescriptor> valueParameters,
@NotNull List<TypeParameterDescriptor> typeParameters,
@NotNull List<String> signatureErrors
@NotNull List<String> signatureErrors,
boolean hasStableParameterNames
) {
super(signatureErrors);
this.returnType = returnType;
this.receiverType = receiverType;
this.valueParameters = valueParameters;
this.typeParameters = typeParameters;
this.hasStableParameterNames = hasStableParameterNames;
}
@Nullable
@@ -79,6 +82,10 @@ public interface ExternalSignatureResolver {
public List<TypeParameterDescriptor> getTypeParameters() {
return typeParameters;
}
public boolean hasStableParameterNames() {
return hasStableParameterNames;
}
}
class AlternativeFieldSignature extends MemberSignature {
@@ -104,9 +111,10 @@ public interface ExternalSignatureResolver {
@NotNull List<ValueParameterDescriptor> valueParameters,
@NotNull List<TypeParameterDescriptor> typeParameters,
@NotNull List<String> signatureErrors,
boolean hasStableParameterNames,
@NotNull List<FunctionDescriptor> superMethods
) {
super(returnType, receiverType, valueParameters, typeParameters, signatureErrors);
super(returnType, receiverType, valueParameters, typeParameters, signatureErrors, hasStableParameterNames);
this.superMethods = superMethods;
}
@@ -133,7 +141,8 @@ public interface ExternalSignatureResolver {
@Nullable JetType returnType,
@Nullable JetType receiverType,
@NotNull List<ValueParameterDescriptor> valueParameters,
@NotNull List<TypeParameterDescriptor> typeParameters
@NotNull List<TypeParameterDescriptor> typeParameters,
boolean hasStableParameterNames
);
@NotNull