Get rid of isConstructorOfStaticNestedClass()
This value can always be computed in ConstructorDescriptorImpl#initialize
This commit is contained in:
+3
-7
@@ -167,13 +167,9 @@ public class ScriptDescriptorImpl extends DeclarationDescriptorNonRootImpl imple
|
|||||||
public static ConstructorDescriptorImpl createConstructor(
|
public static ConstructorDescriptorImpl createConstructor(
|
||||||
@NotNull ScriptDescriptor scriptDescriptor, @NotNull List<ValueParameterDescriptor> valueParameters
|
@NotNull ScriptDescriptor scriptDescriptor, @NotNull List<ValueParameterDescriptor> valueParameters
|
||||||
) {
|
) {
|
||||||
return ConstructorDescriptorImpl.create(scriptDescriptor.getClassDescriptor(), Annotations.EMPTY, true, SourceElement.NO_SOURCE)
|
return ConstructorDescriptorImpl
|
||||||
.initialize(
|
.create(scriptDescriptor.getClassDescriptor(), Annotations.EMPTY, true, SourceElement.NO_SOURCE)
|
||||||
Collections.<TypeParameterDescriptor>emptyList(),
|
.initialize(Collections.<TypeParameterDescriptor>emptyList(), valueParameters, Visibilities.PUBLIC);
|
||||||
valueParameters,
|
|
||||||
Visibilities.PUBLIC,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -1277,12 +1277,9 @@ public class DescriptorResolver {
|
|||||||
parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||||
ConstructorDescriptorImpl constructor = constructorDescriptor.initialize(
|
ConstructorDescriptorImpl constructor = constructorDescriptor.initialize(
|
||||||
typeParameters,
|
typeParameters,
|
||||||
resolveValueParameters(
|
resolveValueParameters(constructorDescriptor, parameterScope, valueParameters, trace),
|
||||||
constructorDescriptor,
|
resolveVisibilityFromModifiers(modifierList, getDefaultConstructorVisibility(classDescriptor))
|
||||||
parameterScope,
|
);
|
||||||
valueParameters, trace),
|
|
||||||
resolveVisibilityFromModifiers(modifierList, getDefaultConstructorVisibility(classDescriptor)),
|
|
||||||
isConstructorOfStaticNestedClass(constructorDescriptor));
|
|
||||||
if (isAnnotationClass(classDescriptor)) {
|
if (isAnnotationClass(classDescriptor)) {
|
||||||
CompileTimeConstantUtils.checkConstructorParametersType(valueParameters, trace);
|
CompileTimeConstantUtils.checkConstructorParametersType(valueParameters, trace);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -281,7 +281,7 @@ public class TaskPrioritizer {
|
|||||||
@NotNull Call call
|
@NotNull Call call
|
||||||
) {
|
) {
|
||||||
for (D extension : descriptors) {
|
for (D extension : descriptors) {
|
||||||
if (DescriptorUtils.isConstructorOfStaticNestedClass(extension)) {
|
if (extension instanceof ConstructorDescriptor && DescriptorUtils.isStaticNestedClass(extension.getContainingDeclaration())) {
|
||||||
// We don't want static nested classes' constructors to be resolved with expectedThisObject
|
// We don't want static nested classes' constructors to be resolved with expectedThisObject
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -56,7 +56,7 @@ public class LazyJavaClassMemberScope(
|
|||||||
internal val _constructors = c.storageManager.createLazyValue {
|
internal val _constructors = c.storageManager.createLazyValue {
|
||||||
jClass.getConstructors().flatMap {
|
jClass.getConstructors().flatMap {
|
||||||
jCtor ->
|
jCtor ->
|
||||||
val constructor = resolveConstructor(jCtor, getContainingDeclaration(), jClass.isStatic())
|
val constructor = resolveConstructor(jCtor, getContainingDeclaration())
|
||||||
val samAdapter = resolveSamAdapter(constructor)
|
val samAdapter = resolveSamAdapter(constructor)
|
||||||
if (samAdapter != null) {
|
if (samAdapter != null) {
|
||||||
samAdapter.setReturnType(containingDeclaration.getDefaultType())
|
samAdapter.setReturnType(containingDeclaration.getDefaultType())
|
||||||
@@ -113,7 +113,7 @@ public class LazyJavaClassMemberScope(
|
|||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resolveConstructor(constructor: JavaMethod, classDescriptor: ClassDescriptor, isStaticClass: Boolean): JavaConstructorDescriptor {
|
private fun resolveConstructor(constructor: JavaMethod, classDescriptor: ClassDescriptor): JavaConstructorDescriptor {
|
||||||
val constructorDescriptor = JavaConstructorDescriptor.createJavaConstructor(
|
val constructorDescriptor = JavaConstructorDescriptor.createJavaConstructor(
|
||||||
classDescriptor, Annotations.EMPTY, /* isPrimary = */ false, c.sourceElementFactory.source(constructor)
|
classDescriptor, Annotations.EMPTY, /* isPrimary = */ false, c.sourceElementFactory.source(constructor)
|
||||||
)
|
)
|
||||||
@@ -125,8 +125,7 @@ public class LazyJavaClassMemberScope(
|
|||||||
constructorDescriptor.initialize(
|
constructorDescriptor.initialize(
|
||||||
classDescriptor.getTypeConstructor().getParameters(),
|
classDescriptor.getTypeConstructor().getParameters(),
|
||||||
effectiveSignature.getValueParameters(),
|
effectiveSignature.getValueParameters(),
|
||||||
constructor.getVisibility(),
|
constructor.getVisibility()
|
||||||
isStaticClass
|
|
||||||
)
|
)
|
||||||
constructorDescriptor.setHasStableParameterNames(effectiveSignature.hasStableParameterNames())
|
constructorDescriptor.setHasStableParameterNames(effectiveSignature.hasStableParameterNames())
|
||||||
constructorDescriptor.setHasSynthesizedParameterNames(valueParameters.hasSynthesizedNames)
|
constructorDescriptor.setHasSynthesizedParameterNames(valueParameters.hasSynthesizedNames)
|
||||||
@@ -157,7 +156,7 @@ public class LazyJavaClassMemberScope(
|
|||||||
else Collections.emptyList<ValueParameterDescriptor>()
|
else Collections.emptyList<ValueParameterDescriptor>()
|
||||||
constructorDescriptor.setHasSynthesizedParameterNames(false)
|
constructorDescriptor.setHasSynthesizedParameterNames(false)
|
||||||
|
|
||||||
constructorDescriptor.initialize(typeParameters, valueParameters, getConstructorVisibility(classDescriptor), jClass.isStatic())
|
constructorDescriptor.initialize(typeParameters, valueParameters, getConstructorVisibility(classDescriptor))
|
||||||
constructorDescriptor.setHasStableParameterNames(true)
|
constructorDescriptor.setHasStableParameterNames(true)
|
||||||
constructorDescriptor.setReturnType(classDescriptor.getDefaultType())
|
constructorDescriptor.setReturnType(classDescriptor.getDefaultType())
|
||||||
c.javaResolverCache.recordConstructor(jClass, constructorDescriptor);
|
c.javaResolverCache.recordConstructor(jClass, constructorDescriptor);
|
||||||
|
|||||||
+1
-6
@@ -210,12 +210,7 @@ public class SingleAbstractMethodUtils {
|
|||||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||||
@Nullable JetType returnType
|
@Nullable JetType returnType
|
||||||
) {
|
) {
|
||||||
result.initialize(
|
result.initialize(typeParameters, valueParameters, original.getVisibility());
|
||||||
typeParameters,
|
|
||||||
valueParameters,
|
|
||||||
original.getVisibility(),
|
|
||||||
original.getExpectedThisObject() == ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-8
@@ -59,19 +59,20 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
|||||||
public ConstructorDescriptorImpl initialize(
|
public ConstructorDescriptorImpl initialize(
|
||||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||||
@NotNull Visibility visibility,
|
@NotNull Visibility visibility
|
||||||
boolean isStatic
|
|
||||||
) {
|
) {
|
||||||
super.initialize(null, isStatic ? NO_RECEIVER_PARAMETER : getExpectedThisObject(getContainingDeclaration()), typeParameters,
|
super.initialize(null, calculateExpectedThisObject(), typeParameters, unsubstitutedValueParameters, null, Modality.FINAL, visibility);
|
||||||
unsubstitutedValueParameters, null, Modality.FINAL, visibility);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static ReceiverParameterDescriptor getExpectedThisObject(@NotNull ClassDescriptor descriptor) {
|
private ReceiverParameterDescriptor calculateExpectedThisObject() {
|
||||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
ClassDescriptor classDescriptor = getContainingDeclaration();
|
||||||
if (containingDeclaration instanceof ClassDescriptor) {
|
if (classDescriptor.isInner()) {
|
||||||
return ((ClassDescriptor) containingDeclaration).getThisAsReceiverParameter();
|
DeclarationDescriptor classContainer = classDescriptor.getContainingDeclaration();
|
||||||
|
if (classContainer instanceof ClassDescriptor) {
|
||||||
|
return ((ClassDescriptor) classContainer).getThisAsReceiverParameter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NO_RECEIVER_PARAMETER;
|
return NO_RECEIVER_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class DescriptorFactory {
|
|||||||
public DefaultConstructorDescriptor(@NotNull ClassDescriptor containingClass, @NotNull SourceElement source) {
|
public DefaultConstructorDescriptor(@NotNull ClassDescriptor containingClass, @NotNull SourceElement source) {
|
||||||
super(containingClass, null, Annotations.EMPTY, true, Kind.DECLARATION, source);
|
super(containingClass, null, Annotations.EMPTY, true, Kind.DECLARATION, source);
|
||||||
initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(),
|
initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(),
|
||||||
getDefaultConstructorVisibility(containingClass), true);
|
getDefaultConstructorVisibility(containingClass));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -315,10 +315,6 @@ public class DescriptorUtils {
|
|||||||
return receiverParameterDescriptor == null ? null : receiverParameterDescriptor.getType();
|
return receiverParameterDescriptor == null ? null : receiverParameterDescriptor.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isConstructorOfStaticNestedClass(@Nullable CallableDescriptor descriptor) {
|
|
||||||
return descriptor instanceof ConstructorDescriptor && isStaticNestedClass(descriptor.getContainingDeclaration());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if descriptor is a class inside another class and does not have access to the outer class
|
* @return true if descriptor is a class inside another class and does not have access to the outer class
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ public class ErrorUtils {
|
|||||||
|
|
||||||
ConstructorDescriptorImpl errorConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE);
|
ConstructorDescriptorImpl errorConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE);
|
||||||
errorConstructor.initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(),
|
errorConstructor.initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(),
|
||||||
Visibilities.INTERNAL, false);
|
Visibilities.INTERNAL);
|
||||||
JetScope memberScope = createErrorScope(getName().asString());
|
JetScope memberScope = createErrorScope(getName().asString());
|
||||||
errorConstructor.setReturnType(
|
errorConstructor.setReturnType(
|
||||||
new ErrorTypeImpl(
|
new ErrorTypeImpl(
|
||||||
|
|||||||
+1
-3
@@ -28,7 +28,6 @@ import org.jetbrains.jet.lang.descriptors.impl.PropertyGetterDescriptorImpl;
|
|||||||
import org.jetbrains.jet.lang.descriptors.impl.PropertySetterDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.PropertySetterDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorFactory;
|
import org.jetbrains.jet.lang.resolve.DescriptorFactory;
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -192,8 +191,7 @@ public class MemberDeserializer {
|
|||||||
descriptor.initialize(
|
descriptor.initialize(
|
||||||
classDescriptor.getTypeConstructor().getParameters(),
|
classDescriptor.getTypeConstructor().getParameters(),
|
||||||
local.getDeserializer().valueParameters(proto, AnnotatedCallableKind.FUNCTION),
|
local.getDeserializer().valueParameters(proto, AnnotatedCallableKind.FUNCTION),
|
||||||
visibility(Flags.VISIBILITY.get(proto.getFlags())),
|
visibility(Flags.VISIBILITY.get(proto.getFlags()))
|
||||||
DescriptorUtils.isConstructorOfStaticNestedClass(descriptor)
|
|
||||||
);
|
);
|
||||||
descriptor.setReturnType(local.getTypeDeserializer().type(proto.getReturnType()));
|
descriptor.setReturnType(local.getTypeDeserializer().type(proto.getReturnType()));
|
||||||
return descriptor;
|
return descriptor;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ private class MissingDependencyErrorClassDescriptor(containing: DeclarationDescr
|
|||||||
|
|
||||||
{
|
{
|
||||||
val emptyConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE)
|
val emptyConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE)
|
||||||
emptyConstructor.initialize(listOf(), listOf(), Visibilities.INTERNAL, false)
|
emptyConstructor.initialize(listOf(), listOf(), Visibilities.INTERNAL)
|
||||||
emptyConstructor.setReturnType(createErrorType("<ERROR RETURN TYPE>"))
|
emptyConstructor.setReturnType(createErrorType("<ERROR RETURN TYPE>"))
|
||||||
initialize(JetScope.EMPTY, setOf(emptyConstructor), emptyConstructor)
|
initialize(JetScope.EMPTY, setOf(emptyConstructor), emptyConstructor)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user