frontend part of KT-1922

VerifyError: Default value of constructor parameter should be resolved to previous parameter, not to property of class
This commit is contained in:
Svetlana Isakova
2012-06-13 20:19:38 +04:00
parent dfd3aac900
commit 56bd86f8aa
2 changed files with 9 additions and 2 deletions
@@ -61,6 +61,7 @@ import org.jetbrains.jet.lang.resolve.calls.CallResolver;
import org.jetbrains.jet.lang.resolve.calls.OverloadResolutionResults;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
@@ -399,7 +400,13 @@ public class BodyResolver {
MutableClassDescriptor classDescriptor = entry.getValue();
ConstructorDescriptor unsubstitutedPrimaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
if (unsubstitutedPrimaryConstructor != null) {
checkDefaultParameterValues(klass.getPrimaryConstructorParameters(), unsubstitutedPrimaryConstructor.getValueParameters(), classDescriptor.getScopeForInitializers());
WritableScope parameterScope = new WritableScopeImpl(classDescriptor.getScopeForSupertypeResolution(), unsubstitutedPrimaryConstructor,
RedeclarationHandler.DO_NOTHING, "Scope with value parameters of a constructor");
for (ValueParameterDescriptor valueParameterDescriptor : unsubstitutedPrimaryConstructor.getValueParameters()) {
parameterScope.addVariableDescriptor(valueParameterDescriptor);
}
parameterScope.changeLockLevel(WritableScope.LockLevel.READING);
checkDefaultParameterValues(klass.getPrimaryConstructorParameters(), unsubstitutedPrimaryConstructor.getValueParameters(), parameterScope);
}
}
}
@@ -898,7 +898,7 @@ public class DescriptorResolver {
);
trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor);
WritableScopeImpl parameterScope = new WritableScopeImpl(
scope, classDescriptor, new TraceBasedRedeclarationHandler(trace), "Scope with value parameters of a constructor");
scope, constructorDescriptor, new TraceBasedRedeclarationHandler(trace), "Scope with value parameters of a constructor");
parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH);
return constructorDescriptor.initialize(
typeParameters,