diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForFunctionDescriptor.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForFunctionDescriptor.java index 988989d6fed..559463c1e51 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForFunctionDescriptor.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForFunctionDescriptor.java @@ -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 { 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), diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java index 238e75e49cf..a56e538d207 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java @@ -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, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java index f8390c66209..072ed89c2ee 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java @@ -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.emptyList(), - getDispatchReceiverParameterIfNeeded(classDescriptor), NO_RECEIVER_PARAMETER); + getDispatchReceiverParameterIfNeeded(classDescriptor), (ReceiverParameterDescriptor) null); PropertyGetterDescriptorImpl getter = DescriptorFactory.createDefaultGetter(propertyDescriptor); PropertySetterDescriptor setter = diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt index bbe826048b0..f079d732198 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt @@ -103,7 +103,7 @@ public class LazyScriptClassMemberScope protected constructor( returnType, listOf(), 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 diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index 1b94fd0fa9f..b027b1c8f68 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -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 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); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java index 74131e533bd..143a6954f02 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java @@ -119,7 +119,7 @@ public class ControlStructureTypingUtils { } function.initialize( null, - ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER, + null, Lists.newArrayList(typeParameter), valueParameters, type, diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ReceiverParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ReceiverParameterDescriptor.java index 6a958811748..371ac6a61f4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ReceiverParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ReceiverParameterDescriptor.java @@ -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(); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ConstructorDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ConstructorDescriptorImpl.java index e0ab3e0f4d1..c820de3f8bd 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ConstructorDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ConstructorDescriptorImpl.java @@ -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 diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java index b12834dab15..ae08b5a0df9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java @@ -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 diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java index c5f382ecae9..9b46d4884bf 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java @@ -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.emptyList(), + return values.initialize(null, null, Collections.emptyList(), Collections.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.emptyList(), + return valueOf.initialize(null, null, Collections.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)); } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java index a1b09a54d31..001d89df8d0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java @@ -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; } /** diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index 58a90ba9039..77119f93c38 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -416,7 +416,7 @@ public class ErrorUtils { ); descriptor.setType(ERROR_PROPERTY_TYPE, Collections.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.emptyList(), // TODO Collections.emptyList(), // TODO createErrorType(""),