Minor. Inline NO_RECEIVER_PARAMETER = null
This commit is contained in:
+1
-3
@@ -22,8 +22,6 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage;
|
||||
|
||||
import static org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
|
||||
public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDescriptor implements AccessorForCallableDescriptor<FunctionDescriptor> {
|
||||
|
||||
private final FunctionDescriptor calleeDescriptor;
|
||||
@@ -39,7 +37,7 @@ public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDe
|
||||
|
||||
initialize(DescriptorUtils.getReceiverParameterType(descriptor.getExtensionReceiverParameter()),
|
||||
descriptor instanceof ConstructorDescriptor || AnnotationsPackage.isPlatformStaticInObjectOrClass(descriptor)
|
||||
? NO_RECEIVER_PARAMETER
|
||||
? null
|
||||
: descriptor.getDispatchReceiverParameter(),
|
||||
copyTypeParameters(descriptor),
|
||||
copyValueParameters(descriptor),
|
||||
|
||||
@@ -47,7 +47,6 @@ import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
import static org.jetbrains.kotlin.diagnostics.Errors.*;
|
||||
import static org.jetbrains.kotlin.resolve.BindingContext.*;
|
||||
import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
@@ -669,7 +668,7 @@ public class BodyResolver {
|
||||
}
|
||||
|
||||
JetScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
|
||||
propertyDescriptor, propertyScope, propertyDescriptor.getTypeParameters(), NO_RECEIVER_PARAMETER, trace);
|
||||
propertyDescriptor, propertyScope, propertyDescriptor.getTypeParameters(), null, trace);
|
||||
JetScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(
|
||||
propertyDescriptor, parentScopeForAccessor, trace);
|
||||
|
||||
@@ -697,7 +696,7 @@ public class BodyResolver {
|
||||
@NotNull JetScope scope
|
||||
) {
|
||||
JetScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
|
||||
propertyDescriptor, scope, propertyDescriptor.getTypeParameters(), NO_RECEIVER_PARAMETER, trace);
|
||||
propertyDescriptor, scope, propertyDescriptor.getTypeParameters(), null, trace);
|
||||
JetType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
if (propertyDescriptor.getCompileTimeInitializer() == null) {
|
||||
expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer,
|
||||
|
||||
@@ -50,7 +50,6 @@ import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
import static org.jetbrains.kotlin.diagnostics.Errors.*;
|
||||
import static org.jetbrains.kotlin.lexer.JetTokens.OVERRIDE_KEYWORD;
|
||||
import static org.jetbrains.kotlin.lexer.JetTokens.VARARG_KEYWORD;
|
||||
@@ -735,7 +734,7 @@ public class DescriptorResolver {
|
||||
ReceiverParameterDescriptor receiverDescriptor =
|
||||
DescriptorFactory.createExtensionReceiverParameterForCallable(propertyDescriptor, receiverType);
|
||||
|
||||
ReceiverParameterDescriptor implicitInitializerReceiver = property.hasDelegate() ? NO_RECEIVER_PARAMETER : receiverDescriptor;
|
||||
ReceiverParameterDescriptor implicitInitializerReceiver = property.hasDelegate() ? null : receiverDescriptor;
|
||||
|
||||
JetScope propertyScope = JetScopeUtils.getPropertyDeclarationInnerScope(propertyDescriptor, scope, typeParameterDescriptors,
|
||||
implicitInitializerReceiver, trace);
|
||||
@@ -1055,7 +1054,7 @@ public class DescriptorResolver {
|
||||
toSourceElement(parameter)
|
||||
);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
getDispatchReceiverParameterIfNeeded(classDescriptor), NO_RECEIVER_PARAMETER);
|
||||
getDispatchReceiverParameterIfNeeded(classDescriptor), (ReceiverParameterDescriptor) null);
|
||||
|
||||
PropertyGetterDescriptorImpl getter = DescriptorFactory.createDefaultGetter(propertyDescriptor);
|
||||
PropertySetterDescriptor setter =
|
||||
|
||||
+2
-2
@@ -103,7 +103,7 @@ public class LazyScriptClassMemberScope protected constructor(
|
||||
returnType,
|
||||
listOf<TypeParameterDescriptor>(),
|
||||
scriptDescriptor.getThisAsReceiverParameter(),
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER
|
||||
null as ReceiverParameterDescriptor?
|
||||
)
|
||||
propertyDescriptor.initialize(null, null)
|
||||
|
||||
@@ -138,7 +138,7 @@ public class LazyScriptClassMemberScope protected constructor(
|
||||
parameter.getType(),
|
||||
listOf(),
|
||||
scriptDescriptor.getThisAsReceiverParameter(),
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER
|
||||
null as ReceiverParameterDescriptor?
|
||||
)
|
||||
propertyDescriptor.initialize(null, null)
|
||||
return propertyDescriptor
|
||||
|
||||
+3
-4
@@ -68,7 +68,6 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
import static org.jetbrains.kotlin.diagnostics.Errors.*;
|
||||
import static org.jetbrains.kotlin.lexer.JetTokens.AS_KEYWORD;
|
||||
import static org.jetbrains.kotlin.lexer.JetTokens.AS_SAFE;
|
||||
@@ -446,13 +445,13 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
ReceiverParameterDescriptor receiverParameterDescriptor = resolutionResult.getReceiverParameterDescriptor();
|
||||
recordThisOrSuperCallInTraceAndCallExtension(context, receiverParameterDescriptor, expression);
|
||||
if (onlyClassReceivers && !isDeclaredInClass(receiverParameterDescriptor)) {
|
||||
return LabelResolver.LabeledReceiverResolutionResult.labelResolutionSuccess(NO_RECEIVER_PARAMETER);
|
||||
return LabelResolver.LabeledReceiverResolutionResult.labelResolutionSuccess(null);
|
||||
}
|
||||
}
|
||||
return resolutionResult;
|
||||
}
|
||||
else {
|
||||
ReceiverParameterDescriptor result = NO_RECEIVER_PARAMETER;
|
||||
ReceiverParameterDescriptor result = null;
|
||||
List<ReceiverParameterDescriptor> receivers = context.scope.getImplicitReceiversHierarchy();
|
||||
if (onlyClassReceivers) {
|
||||
for (ReceiverParameterDescriptor receiver : receivers) {
|
||||
@@ -465,7 +464,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
else if (!receivers.isEmpty()) {
|
||||
result = receivers.get(0);
|
||||
}
|
||||
if (result != NO_RECEIVER_PARAMETER) {
|
||||
if (result != null) {
|
||||
context.trace.record(REFERENCE_TARGET, expression.getInstanceReference(), result.getContainingDeclaration());
|
||||
recordThisOrSuperCallInTraceAndCallExtension(context, result, expression);
|
||||
}
|
||||
|
||||
+1
-1
@@ -119,7 +119,7 @@ public class ControlStructureTypingUtils {
|
||||
}
|
||||
function.initialize(
|
||||
null,
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER,
|
||||
null,
|
||||
Lists.newArrayList(typeParameter),
|
||||
valueParameters,
|
||||
type,
|
||||
|
||||
@@ -23,10 +23,6 @@ import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
public interface ReceiverParameterDescriptor extends ParameterDescriptor {
|
||||
|
||||
// This field exists for better readability of the client code
|
||||
@Nullable
|
||||
ReceiverParameterDescriptor NO_RECEIVER_PARAMETER = null;
|
||||
|
||||
@NotNull
|
||||
ReceiverValue getValue();
|
||||
|
||||
|
||||
+1
-3
@@ -26,8 +26,6 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
|
||||
public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements ConstructorDescriptor {
|
||||
|
||||
protected final boolean isPrimary;
|
||||
@@ -74,7 +72,7 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
return ((ClassDescriptor) classContainer).getThisAsReceiverParameter();
|
||||
}
|
||||
}
|
||||
return NO_RECEIVER_PARAMETER;
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -89,12 +89,12 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
@Override
|
||||
public ReceiverParameterDescriptor getExtensionReceiverParameter() {
|
||||
return ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReceiverParameterDescriptor getDispatchReceiverParameter() {
|
||||
return ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.types.Variance;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.getDefaultConstructorVisibility;
|
||||
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getBuiltIns;
|
||||
|
||||
@@ -88,7 +87,7 @@ public class DescriptorFactory {
|
||||
SimpleFunctionDescriptorImpl values =
|
||||
SimpleFunctionDescriptorImpl.create(enumClass, Annotations.EMPTY, DescriptorUtils.ENUM_VALUES,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, enumClass.getSource());
|
||||
return values.initialize(null, NO_RECEIVER_PARAMETER, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
return values.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.<ValueParameterDescriptor>emptyList(),
|
||||
getBuiltIns(enumClass).getArrayType(Variance.INVARIANT, enumClass.getDefaultType()), Modality.FINAL,
|
||||
Visibilities.PUBLIC);
|
||||
@@ -103,7 +102,7 @@ public class DescriptorFactory {
|
||||
valueOf, null, 0, Annotations.EMPTY, Name.identifier("value"), getBuiltIns(enumClass).getStringType(), false, null,
|
||||
enumClass.getSource()
|
||||
);
|
||||
return valueOf.initialize(null, NO_RECEIVER_PARAMETER, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
return valueOf.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.singletonList(parameterDescriptor), enumClass.getDefaultType(), Modality.FINAL,
|
||||
Visibilities.PUBLIC);
|
||||
}
|
||||
@@ -114,7 +113,7 @@ public class DescriptorFactory {
|
||||
@Nullable JetType receiverParameterType
|
||||
) {
|
||||
return receiverParameterType == null
|
||||
? NO_RECEIVER_PARAMETER
|
||||
? null
|
||||
: new ReceiverParameterDescriptorImpl(owner, new ExtensionReceiver(owner, receiverParameterType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isAny;
|
||||
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.*;
|
||||
import static org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getBuiltIns;
|
||||
|
||||
public class DescriptorUtils {
|
||||
@@ -66,7 +65,7 @@ public class DescriptorUtils {
|
||||
ScriptDescriptor scriptDescriptor = (ScriptDescriptor) containingDeclaration;
|
||||
return scriptDescriptor.getThisAsReceiverParameter();
|
||||
}
|
||||
return NO_RECEIVER_PARAMETER;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -416,7 +416,7 @@ public class ErrorUtils {
|
||||
);
|
||||
descriptor.setType(ERROR_PROPERTY_TYPE,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER,
|
||||
null,
|
||||
(JetType) null
|
||||
);
|
||||
|
||||
@@ -428,7 +428,7 @@ public class ErrorUtils {
|
||||
ErrorSimpleFunctionDescriptorImpl function = new ErrorSimpleFunctionDescriptorImpl(ERROR_CLASS, ownerScope);
|
||||
function.initialize(
|
||||
null,
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER,
|
||||
null,
|
||||
Collections.<TypeParameterDescriptorImpl>emptyList(), // TODO
|
||||
Collections.<ValueParameterDescriptor>emptyList(), // TODO
|
||||
createErrorType("<ERROR FUNCTION RETURN TYPE>"),
|
||||
|
||||
Reference in New Issue
Block a user