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