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:
@@ -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.OverloadResolutionResults;
|
||||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
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.WritableScope;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||||
@@ -399,7 +400,13 @@ public class BodyResolver {
|
|||||||
MutableClassDescriptor classDescriptor = entry.getValue();
|
MutableClassDescriptor classDescriptor = entry.getValue();
|
||||||
ConstructorDescriptor unsubstitutedPrimaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
|
ConstructorDescriptor unsubstitutedPrimaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
|
||||||
if (unsubstitutedPrimaryConstructor != null) {
|
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);
|
trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor);
|
||||||
WritableScopeImpl parameterScope = new WritableScopeImpl(
|
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);
|
parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||||
return constructorDescriptor.initialize(
|
return constructorDescriptor.initialize(
|
||||||
typeParameters,
|
typeParameters,
|
||||||
|
|||||||
Reference in New Issue
Block a user