NO_RECEIVER_PARAMETER is now simply null
This commit is contained in:
@@ -159,7 +159,7 @@ public final class TipsManager {
|
||||
Collections2.filter(JetScopeUtils.getAllExtensions(scope), new Predicate<CallableDescriptor>() {
|
||||
@Override
|
||||
public boolean apply(CallableDescriptor callableDescriptor) {
|
||||
if (!callableDescriptor.getReceiverParameter().exists()) {
|
||||
if (callableDescriptor.getReceiverParameter() == null) {
|
||||
return false;
|
||||
}
|
||||
for (ReceiverParameterDescriptor receiverDescriptor : result) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -35,13 +36,13 @@ public class AccessorForFunctionDescriptor extends SimpleFunctionDescriptorImpl
|
||||
|
||||
FunctionDescriptor fd = (FunctionDescriptor) descriptor;
|
||||
|
||||
initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null,
|
||||
descriptor instanceof ConstructorDescriptor ? NO_RECEIVER_PARAMETER : fd.getExpectedThisObject(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
fd.getValueParameters(),
|
||||
fd.getReturnType(),
|
||||
Modality.FINAL,
|
||||
Visibilities.INTERNAL,
|
||||
initialize(DescriptorUtils.getReceiverParameterType(fd.getReceiverParameter()),
|
||||
descriptor instanceof ConstructorDescriptor ? NO_RECEIVER_PARAMETER : fd.getExpectedThisObject(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
fd.getValueParameters(),
|
||||
fd.getReturnType(),
|
||||
Modality.FINAL,
|
||||
Visibilities.INTERNAL,
|
||||
/*isInline = */ false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
@@ -32,7 +33,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptor {
|
||||
pd.isVar(), Name.identifier(pd.getName() + "$b$" + index),
|
||||
Kind.DECLARATION);
|
||||
|
||||
JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null;
|
||||
JetType receiverType = DescriptorUtils.getReceiverParameterType(pd.getReceiverParameter());
|
||||
setType(pd.getType(), Collections.<TypeParameterDescriptorImpl>emptyList(), pd.getExpectedThisObject(), receiverType);
|
||||
initialize(new Getter(this), new Setter(this));
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
|
||||
final ReceiverParameterDescriptor receiver = funDescriptor.getReceiverParameter();
|
||||
int count = 1;
|
||||
if (receiver.exists()) {
|
||||
if (receiver != null) {
|
||||
StackValue.local(count, OBJECT_TYPE).put(OBJECT_TYPE, iv);
|
||||
StackValue.onStack(OBJECT_TYPE)
|
||||
.upcast(typeMapper.mapType(receiver.getType()), iv);
|
||||
|
||||
@@ -69,12 +69,13 @@ public class CodegenUtil {
|
||||
public static SimpleFunctionDescriptor createInvoke(FunctionDescriptor fd) {
|
||||
int arity = fd.getValueParameters().size();
|
||||
SimpleFunctionDescriptorImpl invokeDescriptor = new SimpleFunctionDescriptorImpl(
|
||||
fd.getExpectedThisObject().exists() ? KotlinBuiltIns.getInstance().getExtensionFunction(arity) : KotlinBuiltIns.getInstance().getFunction(arity),
|
||||
fd.getExpectedThisObject() != null
|
||||
? KotlinBuiltIns.getInstance().getExtensionFunction(arity) : KotlinBuiltIns.getInstance().getFunction(arity),
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Name.identifier("invoke"),
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
|
||||
invokeDescriptor.initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null,
|
||||
invokeDescriptor.initialize(DescriptorUtils.getReceiverParameterType(fd.getReceiverParameter()),
|
||||
fd.getExpectedThisObject(),
|
||||
Collections.<TypeParameterDescriptorImpl>emptyList(),
|
||||
fd.getValueParameters(),
|
||||
@@ -121,7 +122,7 @@ public class CodegenUtil {
|
||||
@NotNull
|
||||
public static JvmClassName getInternalClassName(FunctionDescriptor descriptor) {
|
||||
final int paramCount = descriptor.getValueParameters().size();
|
||||
if (descriptor.getReceiverParameter().exists()) {
|
||||
if (descriptor.getReceiverParameter() != null) {
|
||||
return JvmClassName.byInternalName("jet/ExtensionFunction" + paramCount);
|
||||
}
|
||||
else {
|
||||
@@ -136,7 +137,7 @@ public class CodegenUtil {
|
||||
signatureWriter.writeFormalTypeParametersStart();
|
||||
signatureWriter.writeFormalTypeParametersEnd();
|
||||
|
||||
boolean isExtensionFunction = fd.getReceiverParameter().exists();
|
||||
boolean isExtensionFunction = fd.getReceiverParameter() != null;
|
||||
int paramCount = fd.getValueParameters().size();
|
||||
if (isExtensionFunction) {
|
||||
paramCount++;
|
||||
|
||||
@@ -1379,7 +1379,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
final StackValue.Property iValue =
|
||||
intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression) r : null);
|
||||
if (!directToField && resolvedCall != null && !isSuper) {
|
||||
receiver.put(propertyDescriptor.getReceiverParameter().exists() || isStatic
|
||||
receiver.put(propertyDescriptor.getReceiverParameter() != null || isStatic
|
||||
? receiver.type
|
||||
: iValue.methodOwner.getAsmType(), v);
|
||||
}
|
||||
@@ -1566,7 +1566,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
getter = null;
|
||||
}
|
||||
|
||||
if (getter == null && propertyDescriptor.getReceiverParameter().exists()) {
|
||||
if (getter == null && propertyDescriptor.getReceiverParameter() != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
@@ -1586,7 +1586,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
setter = null;
|
||||
}
|
||||
|
||||
if (setter == null && propertyDescriptor.isVar() && propertyDescriptor.getReceiverParameter().exists()) {
|
||||
if (setter == null && propertyDescriptor.isVar() && propertyDescriptor.getReceiverParameter() != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
@@ -3018,7 +3018,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
gen(array, asmType(((ClassDescriptor) getterDescriptor.getContainingDeclaration()).getDefaultType()));
|
||||
}
|
||||
|
||||
if (getterDescriptor.getReceiverParameter().exists()) {
|
||||
if (getterDescriptor.getReceiverParameter() != null) {
|
||||
index++;
|
||||
}
|
||||
asmType = accessor.getSignature().getAsmMethod().getReturnType();
|
||||
@@ -3033,7 +3033,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
gen(array, arrayType);
|
||||
}
|
||||
|
||||
if (setterDescriptor.getReceiverParameter().exists()) {
|
||||
if (setterDescriptor.getReceiverParameter() != null) {
|
||||
index++;
|
||||
}
|
||||
asmType = argumentTypes[argumentTypes.length - 1];
|
||||
|
||||
@@ -147,7 +147,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
|
||||
Type thisType;
|
||||
ReceiverParameterDescriptor expectedThisObject = functionDescriptor.getExpectedThisObject();
|
||||
if (expectedThisObject.exists()) {
|
||||
if (expectedThisObject != null) {
|
||||
thisType = typeMapper.mapType(expectedThisObject.getType());
|
||||
}
|
||||
else if (fun instanceof JetFunctionLiteralExpression || isLocalFun(bindingContext, functionDescriptor)) {
|
||||
@@ -188,7 +188,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
add++;
|
||||
}
|
||||
|
||||
if (functionDescriptor.getReceiverParameter().exists()) {
|
||||
if (functionDescriptor.getReceiverParameter() != null) {
|
||||
add++;
|
||||
}
|
||||
|
||||
@@ -258,8 +258,9 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
mv.visitLocalVariable("this", thisType.getDescriptor(), null, methodBegin, methodEnd, k++);
|
||||
}
|
||||
|
||||
if (functionDescriptor.getReceiverParameter().exists()) {
|
||||
Type type = typeMapper.mapType(functionDescriptor.getReceiverParameter().getType());
|
||||
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
||||
if (receiverParameter != null) {
|
||||
Type type = typeMapper.mapType(receiverParameter.getType());
|
||||
mv.visitLocalVariable(JvmAbi.RECEIVER_PARAMETER, type.getDescriptor(), null, methodBegin, methodEnd, k);
|
||||
k += type.getSize();
|
||||
}
|
||||
@@ -430,7 +431,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
final List<JvmMethodParameterSignature> kotlinParameterTypes = jvmSignature.getKotlinParameterTypes();
|
||||
assert kotlinParameterTypes != null;
|
||||
|
||||
if (receiverParameter.exists()) {
|
||||
if (receiverParameter != null) {
|
||||
JetValueParameterAnnotationWriter av = JetValueParameterAnnotationWriter.visitParameterAnnotation(mv, start++);
|
||||
av.writeName(JvmAbi.RECEIVER_PARAMETER);
|
||||
av.writeReceiver();
|
||||
@@ -546,7 +547,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
}
|
||||
|
||||
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
||||
boolean hasReceiver = receiverParameter.exists();
|
||||
boolean hasReceiver = receiverParameter != null;
|
||||
boolean isStatic = isStatic(kind);
|
||||
|
||||
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
||||
((ClassDescriptorImpl)classDescriptor).initialize(
|
||||
false,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.singleton((funDescriptor.getReceiverParameter().exists()
|
||||
Collections.singleton((funDescriptor.getReceiverParameter() != null
|
||||
? KotlinBuiltIns.getInstance().getExtensionFunction(arity)
|
||||
: KotlinBuiltIns.getInstance().getFunction(arity)).getDefaultType()), JetScope.EMPTY,
|
||||
Collections.<ConstructorDescriptor>emptySet(), null);
|
||||
|
||||
@@ -183,7 +183,7 @@ public class CodegenBinding {
|
||||
? ((PropertyAccessorDescriptor) enclosingReceiver).getCorrespondingProperty()
|
||||
: enclosingReceiver;
|
||||
|
||||
if (!enclosingReceiver.getReceiverParameter().exists()) {
|
||||
if (enclosingReceiver.getReceiverParameter() == null) {
|
||||
enclosingReceiver = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public abstract class CodegenContext {
|
||||
public final CallableDescriptor getCallableDescriptorWithReceiver() {
|
||||
if (contextDescriptor instanceof CallableDescriptor) {
|
||||
final CallableDescriptor callableDescriptor = (CallableDescriptor) getContextDescriptor();
|
||||
return callableDescriptor.getReceiverParameter().exists() ? callableDescriptor : null;
|
||||
return callableDescriptor.getReceiverParameter() != null ? callableDescriptor : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public interface LocalLookup {
|
||||
@Override
|
||||
public StackValue outerValue(EnclosedValueDescriptor d, ExpressionCodegen expressionCodegen) {
|
||||
CallableDescriptor descriptor = (FunctionDescriptor) d.getDescriptor();
|
||||
return StackValue.local(descriptor.getExpectedThisObject().exists() ? 1 : 0, d.getType());
|
||||
return StackValue.local(descriptor.getExpectedThisObject() != null ? 1 : 0, d.getType());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ public class IntrinsicMethods {
|
||||
|
||||
if (descriptor instanceof SimpleFunctionDescriptor) {
|
||||
SimpleFunctionDescriptor functionDescriptor = (SimpleFunctionDescriptor) descriptor;
|
||||
if (!functionDescriptor.getReceiverParameter().exists()) {
|
||||
if (functionDescriptor.getReceiverParameter() == null) {
|
||||
FqNameUnsafe ownerFqName = DescriptorUtils.getFQName(descriptor.getContainingDeclaration());
|
||||
if (ownerFqName.equalsTo("jet.String")) {
|
||||
return new PsiMethodCall(functionDescriptor);
|
||||
|
||||
@@ -460,8 +460,9 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
|
||||
Type receiverParameterType;
|
||||
if (functionDescriptor.getReceiverParameter().exists()) {
|
||||
receiverParameterType = mapType(functionDescriptor.getOriginal().getReceiverParameter().getType());
|
||||
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getOriginal().getReceiverParameter();
|
||||
if (receiverParameter != null) {
|
||||
receiverParameterType = mapType(receiverParameter.getType());
|
||||
}
|
||||
else {
|
||||
receiverParameterType = null;
|
||||
@@ -499,8 +500,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
writeFormalTypeParameters(f.getTypeParameters(), signatureVisitor);
|
||||
|
||||
final ReceiverParameterDescriptor receiverTypeRef = f.getReceiverParameter();
|
||||
final JetType receiverType = !receiverTypeRef.exists() ? null : receiverTypeRef.getType();
|
||||
final JetType receiverType = DescriptorUtils.getReceiverParameterType(f.getReceiverParameter());
|
||||
final List<ValueParameterDescriptor> parameters = f.getValueParameters();
|
||||
|
||||
signatureVisitor.writeParametersStart();
|
||||
@@ -547,7 +547,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
}
|
||||
|
||||
private void writeThisForAccessorIfNeeded(FunctionDescriptor f, BothSignatureWriter signatureVisitor) {
|
||||
if (isAccessor(f) && f.getExpectedThisObject().exists()) {
|
||||
if (isAccessor(f) && f.getExpectedThisObject() != null) {
|
||||
signatureVisitor.writeParameterType(JvmMethodParameterKind.THIS);
|
||||
mapType(((ClassifierDescriptor) f.getContainingDeclaration()).getDefaultType(), signatureVisitor, JetTypeMapperMode.VALUE);
|
||||
signatureVisitor.writeParameterTypeEnd();
|
||||
@@ -637,8 +637,8 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
return signatureWriter.makeJvmMethodSignature(name.getName());
|
||||
}
|
||||
|
||||
private void writeReceiverIfNeeded(ReceiverParameterDescriptor receiver, BothSignatureWriter signatureWriter) {
|
||||
if (receiver.exists()) {
|
||||
private void writeReceiverIfNeeded(@Nullable ReceiverParameterDescriptor receiver, BothSignatureWriter signatureWriter) {
|
||||
if (receiver != null) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
||||
mapType(receiver.getType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
signatureWriter.writeParameterTypeEnd();
|
||||
@@ -895,8 +895,9 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
JvmMethodSignature descriptor = erasedInvokeSignature(fd);
|
||||
JvmClassName owner = getInternalClassName(fd);
|
||||
Type receiverParameterType;
|
||||
if (fd.getReceiverParameter().exists()) {
|
||||
receiverParameterType = mapType(fd.getOriginal().getReceiverParameter().getType());
|
||||
ReceiverParameterDescriptor receiverParameter = fd.getOriginal().getReceiverParameter();
|
||||
if (receiverParameter != null) {
|
||||
receiverParameterType = mapType(receiverParameter.getType());
|
||||
}
|
||||
else {
|
||||
receiverParameterType = null;
|
||||
|
||||
+2
-5
@@ -19,10 +19,7 @@ package org.jetbrains.jet.lang.resolve.java.resolver;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.constants.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
||||
@@ -155,7 +152,7 @@ public final class JavaCompileTimeConstResolver {
|
||||
Name identifier = Name.identifier(((PsiEnumConstant) resolveElement).getName());
|
||||
Collection<VariableDescriptor> properties = scope.getProperties(identifier);
|
||||
for (VariableDescriptor variableDescriptor : properties) {
|
||||
if (!variableDescriptor.getReceiverParameter().exists()) {
|
||||
if (variableDescriptor.getReceiverParameter() == null) {
|
||||
return new EnumValue((PropertyDescriptor) variableDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ import java.util.Set;
|
||||
* @author abreslav
|
||||
*/
|
||||
public interface CallableDescriptor extends DeclarationDescriptorWithVisibility, DeclarationDescriptorNonRoot {
|
||||
@NotNull
|
||||
@Nullable
|
||||
ReceiverParameterDescriptor getReceiverParameter();
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
ReceiverParameterDescriptor getExpectedThisObject();
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -56,7 +57,7 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
private static ReceiverParameterDescriptor getExpectedThisObject(@NotNull ClassDescriptor descriptor) {
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
return DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration);
|
||||
|
||||
+10
-7
@@ -72,7 +72,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
protected FunctionDescriptorImpl initialize(
|
||||
@Nullable JetType receiverParameterType,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@Nullable ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable JetType unsubstitutedReturnType,
|
||||
@@ -117,13 +117,13 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
this.unsubstitutedReturnType = unsubstitutedReturnType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
@Override
|
||||
public ReceiverParameterDescriptor getReceiverParameter() {
|
||||
return receiverParameter;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
@Override
|
||||
public ReceiverParameterDescriptor getExpectedThisObject() {
|
||||
return expectedThisObject;
|
||||
@@ -196,16 +196,19 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
|
||||
|
||||
JetType substitutedReceiverParameterType = null;
|
||||
if (receiverParameter.exists()) {
|
||||
if (receiverParameter != null) {
|
||||
substitutedReceiverParameterType = substitutor.substitute(getReceiverParameter().getType(), Variance.IN_VARIANCE);
|
||||
if (substitutedReceiverParameterType == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
ReceiverParameterDescriptor substitutedExpectedThis = expectedThisObject.substitute(substitutor);
|
||||
if (substitutedExpectedThis == null) {
|
||||
return null;
|
||||
ReceiverParameterDescriptor substitutedExpectedThis = null;
|
||||
if (expectedThisObject != null) {
|
||||
substitutedExpectedThis = expectedThisObject.substitute(substitutor);
|
||||
if (substitutedExpectedThis == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
List<ValueParameterDescriptor> substitutedValueParameters = FunctionDescriptorUtil.getSubstitutedValueParameters(substitutedDescriptor, this, substitutor);
|
||||
|
||||
+8
-3
@@ -105,7 +105,7 @@ public class FunctionDescriptorUtil {
|
||||
public static JetScope getFunctionInnerScope(@NotNull JetScope outerScope, @NotNull FunctionDescriptor descriptor, @NotNull BindingTrace trace) {
|
||||
WritableScope parameterScope = new WritableScopeImpl(outerScope, descriptor, new TraceBasedRedeclarationHandler(trace), "Function inner scope");
|
||||
ReceiverParameterDescriptor receiver = descriptor.getReceiverParameter();
|
||||
if (receiver.exists()) {
|
||||
if (receiver != null) {
|
||||
parameterScope.setImplicitReceiver(receiver);
|
||||
}
|
||||
for (TypeParameterDescriptor typeParameter : descriptor.getTypeParameters()) {
|
||||
@@ -119,8 +119,13 @@ public class FunctionDescriptorUtil {
|
||||
return parameterScope;
|
||||
}
|
||||
|
||||
public static void initializeFromFunctionType(@NotNull FunctionDescriptorImpl functionDescriptor, @NotNull JetType functionType, @NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull Modality modality, @NotNull Visibility visibility) {
|
||||
public static void initializeFromFunctionType(
|
||||
@NotNull FunctionDescriptorImpl functionDescriptor,
|
||||
@NotNull JetType functionType,
|
||||
@Nullable ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull Modality modality,
|
||||
@NotNull Visibility visibility
|
||||
) {
|
||||
|
||||
assert KotlinBuiltIns.getInstance().isFunctionType(functionType);
|
||||
functionDescriptor.initialize(KotlinBuiltIns.getInstance().getReceiverType(functionType),
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/*package*/ class NoReceiverParameter implements ReceiverParameterDescriptor {
|
||||
/*package*/ static final ReceiverParameterDescriptor INSTANCE = new NoReceiverParameter();
|
||||
|
||||
private NoReceiverParameter() {}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType() {
|
||||
throw new UnsupportedOperationException("NO_RECEIVER_PARAMETER.getType()");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverValue getValue() {
|
||||
return ReceiverValue.NO_RECEIVER;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getOriginal() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DeclarationDescriptor getContainingDeclaration() {
|
||||
throw new UnsupportedOperationException("NO_RECEIVER_PARAMETER.getContainingDeclaration()");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ReceiverParameterDescriptor substitute(TypeSubstitutor substitutor) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(DeclarationDescriptorVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitReceiverParameterDescriptor(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptVoid(DeclarationDescriptorVisitor<Void, Void> visitor) {
|
||||
visitor.visitReceiverParameterDescriptor(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NO_RECEIVER_PARAMETER";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AnnotationDescriptor> getAnnotations() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getName() {
|
||||
throw new UnsupportedOperationException("NO_RECEIVER_PARAMETER.getName()");
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
@@ -106,13 +107,13 @@ public abstract class PropertyAccessorDescriptor extends DeclarationDescriptorNo
|
||||
return correspondingProperty;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
@Override
|
||||
public ReceiverParameterDescriptor getReceiverParameter() {
|
||||
return getCorrespondingProperty().getReceiverParameter();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
@Override
|
||||
public ReceiverParameterDescriptor getExpectedThisObject() {
|
||||
return getCorrespondingProperty().getExpectedThisObject();
|
||||
|
||||
@@ -89,7 +89,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
@NotNull Visibility visibility,
|
||||
boolean isVar,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@Nullable ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull Name name,
|
||||
@NotNull JetType outType,
|
||||
@NotNull Kind kind
|
||||
@@ -101,7 +101,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
public void setType(
|
||||
@NotNull JetType outType,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@Nullable ReceiverParameterDescriptor expectedThisObject,
|
||||
@Nullable JetType receiverType
|
||||
) {
|
||||
ReceiverParameterDescriptor receiverParameter = DescriptorResolver.resolveReceiverParameterFor(this, receiverType);
|
||||
@@ -111,8 +111,8 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
public void setType(
|
||||
@NotNull JetType outType,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull ReceiverParameterDescriptor receiverParameter
|
||||
@Nullable ReceiverParameterDescriptor expectedThisObject,
|
||||
@Nullable ReceiverParameterDescriptor receiverParameter
|
||||
) {
|
||||
setOutType(outType);
|
||||
|
||||
@@ -138,12 +138,12 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@Nullable
|
||||
public ReceiverParameterDescriptor getReceiverParameter() {
|
||||
return receiverParameter;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
@Override
|
||||
public ReceiverParameterDescriptor getExpectedThisObject() {
|
||||
return expectedThisObject;
|
||||
@@ -216,10 +216,19 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
return null; // TODO : tell the user that the property was projected out
|
||||
}
|
||||
|
||||
ReceiverParameterDescriptor substitutedExpectedThisObject = getExpectedThisObject().substitute(substitutor);
|
||||
|
||||
ReceiverParameterDescriptor substitutedExpectedThisObject;
|
||||
ReceiverParameterDescriptor expectedThisObject = getExpectedThisObject();
|
||||
if (expectedThisObject != null) {
|
||||
substitutedExpectedThisObject = expectedThisObject.substitute(substitutor);
|
||||
if (substitutedExpectedThisObject == null) return null;
|
||||
}
|
||||
else {
|
||||
substitutedExpectedThisObject = null;
|
||||
}
|
||||
|
||||
JetType substitutedReceiverType;
|
||||
if (receiverParameter.exists()) {
|
||||
if (receiverParameter != null) {
|
||||
substitutedReceiverType = substitutor.substitute(receiverParameter.getType(), Variance.IN_VARIANCE);
|
||||
if (substitutedReceiverType == null) return null;
|
||||
}
|
||||
|
||||
+3
-4
@@ -27,8 +27,9 @@ import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
*/
|
||||
public interface ReceiverParameterDescriptor extends DeclarationDescriptor {
|
||||
|
||||
// NOTE: Instead of comparing to NO_RECEIVER_PARAMETER, call exists()
|
||||
ReceiverParameterDescriptor NO_RECEIVER_PARAMETER = NoReceiverParameter.INSTANCE;
|
||||
// This field exists for better readability of the client code
|
||||
@Nullable
|
||||
ReceiverParameterDescriptor NO_RECEIVER_PARAMETER = null;
|
||||
|
||||
@NotNull
|
||||
JetType getType();
|
||||
@@ -40,8 +41,6 @@ public interface ReceiverParameterDescriptor extends DeclarationDescriptor {
|
||||
@NotNull
|
||||
DeclarationDescriptor getContainingDeclaration();
|
||||
|
||||
boolean exists();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
ReceiverParameterDescriptor substitute(TypeSubstitutor substitutor);
|
||||
|
||||
-5
@@ -52,9 +52,4 @@ public class ReceiverParameterDescriptorImpl extends AbstractReceiverParameterDe
|
||||
public DeclarationDescriptor getContainingDeclaration() {
|
||||
return containingDeclaration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
|
||||
public SimpleFunctionDescriptorImpl initialize(
|
||||
@Nullable JetType receiverParameterType,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@Nullable ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable JetType unsubstitutedReturnType,
|
||||
|
||||
@@ -86,13 +86,11 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverParameterDescriptor getReceiverParameter() {
|
||||
return ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverParameterDescriptor getExpectedThisObject() {
|
||||
return ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
|
||||
@@ -26,23 +26,23 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetClass;
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintsUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.Variance;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
import static org.jetbrains.jet.lang.diagnostics.rendering.TabledDescriptorRenderer.*;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData.ExtendedInferenceErrorData;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.diagnostics.rendering.TabledDescriptorRenderer.*;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData.ExtendedInferenceErrorData;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
@@ -193,7 +193,7 @@ public class Renderers {
|
||||
.text("None of the following substitutions");
|
||||
|
||||
for (CallableDescriptor substitutedDescriptor : substitutedDescriptors) {
|
||||
JetType receiverType = substitutedDescriptor.getReceiverParameter().exists() ? substitutedDescriptor.getReceiverParameter().getType() : null;
|
||||
JetType receiverType = DescriptorUtils.getReceiverParameterType(substitutedDescriptor.getReceiverParameter());
|
||||
|
||||
final Collection<ConstraintPosition> errorPositions = Sets.newHashSet();
|
||||
List<JetType> parameterTypes = Lists.newArrayList();
|
||||
|
||||
@@ -300,7 +300,7 @@ public class DeclarationResolver {
|
||||
public boolean apply(@Nullable DeclarationDescriptor descriptor) {
|
||||
if (descriptor instanceof PropertyDescriptor) {
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor)descriptor;
|
||||
return !propertyDescriptor.getReceiverParameter().exists();
|
||||
return propertyDescriptor.getReceiverParameter() == null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -840,7 +840,7 @@ public class DescriptorResolver {
|
||||
|
||||
public JetScope getPropertyDeclarationInnerScope(
|
||||
@NotNull JetScope outerScope, @NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull ReceiverParameterDescriptor receiver, BindingTrace trace
|
||||
@Nullable ReceiverParameterDescriptor receiver, BindingTrace trace
|
||||
) {
|
||||
WritableScopeImpl result = new WritableScopeImpl(
|
||||
outerScope, outerScope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(trace),
|
||||
@@ -848,7 +848,7 @@ public class DescriptorResolver {
|
||||
for (TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
|
||||
result.addTypeParameterDescriptor(typeParameterDescriptor);
|
||||
}
|
||||
if (receiver.exists()) {
|
||||
if (receiver != null) {
|
||||
result.setImplicitReceiver(receiver);
|
||||
}
|
||||
result.changeLockLevel(WritableScope.LockLevel.READING);
|
||||
@@ -1314,11 +1314,6 @@ public class DescriptorResolver {
|
||||
return classDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "class " + classDescriptor.getName() + "::this";
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.jet.lang.types.DescriptorSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
@@ -54,13 +55,13 @@ public class DescriptorUtils {
|
||||
|
||||
return substitutedFunction;
|
||||
}
|
||||
|
||||
|
||||
public static Modality convertModality(Modality modality, boolean makeNonAbstract) {
|
||||
if (makeNonAbstract && modality == Modality.ABSTRACT) return Modality.OPEN;
|
||||
return modality;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
public static ReceiverParameterDescriptor getExpectedThisObjectIfNeeded(@NotNull DeclarationDescriptor containingDeclaration) {
|
||||
if (containingDeclaration instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
||||
@@ -144,8 +145,8 @@ public class DescriptorUtils {
|
||||
@Nullable
|
||||
public static <D extends DeclarationDescriptor> D getParentOfType(@Nullable DeclarationDescriptor descriptor, @NotNull Class<D> aClass) {
|
||||
return getParentOfType(descriptor, aClass, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <D extends DeclarationDescriptor> D getParentOfType(@Nullable DeclarationDescriptor descriptor, @NotNull Class<D> aClass, boolean strict) {
|
||||
if (descriptor == null) return null;
|
||||
@@ -161,7 +162,7 @@ public class DescriptorUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isAncestor(@Nullable DeclarationDescriptor ancestor, @NotNull DeclarationDescriptor declarationDescriptor, boolean strict) {
|
||||
if (ancestor == null) return false;
|
||||
DeclarationDescriptor descriptor = strict ? declarationDescriptor.getContainingDeclaration() : declarationDescriptor;
|
||||
@@ -175,7 +176,7 @@ public class DescriptorUtils {
|
||||
@Nullable
|
||||
public static VariableDescriptor filterNonExtensionProperty(Collection<VariableDescriptor> variables) {
|
||||
for (VariableDescriptor variable : variables) {
|
||||
if (!variable.getReceiverParameter().exists()) {
|
||||
if (variable.getReceiverParameter() == null) {
|
||||
return variable;
|
||||
}
|
||||
}
|
||||
@@ -344,7 +345,7 @@ public class DescriptorUtils {
|
||||
assert classKind == ClassKind.CLASS || classKind == ClassKind.TRAIT || classKind == ClassKind.ANNOTATION_CLASS;
|
||||
return Visibilities.PUBLIC;
|
||||
}
|
||||
|
||||
|
||||
public static List<String> getSortedValueArguments(AnnotationDescriptor descriptor) {
|
||||
List<String> resultList = Lists.newArrayList();
|
||||
for (Map.Entry<ValueParameterDescriptor, CompileTimeConstant<?>> entry : descriptor.getAllValueArguments().entrySet()) {
|
||||
@@ -368,4 +369,21 @@ public class DescriptorUtils {
|
||||
assert constructors.size() == 1 : "Data class must have only one constructor: " + constructors;
|
||||
return constructors.iterator().next();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetType getReceiverParameterType(@Nullable ReceiverParameterDescriptor receiverParameterDescriptor) {
|
||||
if (receiverParameterDescriptor == null) {
|
||||
return null;
|
||||
}
|
||||
return receiverParameterDescriptor.getType();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ReceiverValue safeGetValue(@Nullable ReceiverParameterDescriptor receiverParameterDescriptor) {
|
||||
if (receiverParameterDescriptor == null) {
|
||||
return ReceiverValue.NO_RECEIVER;
|
||||
}
|
||||
return receiverParameterDescriptor.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class OverridingUtil {
|
||||
private static List<JetType> compiledValueParameters(CallableDescriptor callableDescriptor) {
|
||||
ReceiverParameterDescriptor receiverParameter = callableDescriptor.getReceiverParameter();
|
||||
ArrayList<JetType> parameters = new ArrayList<JetType>();
|
||||
if (receiverParameter.exists()) {
|
||||
if (receiverParameter != null) {
|
||||
parameters.add(receiverParameter.getType());
|
||||
}
|
||||
for (ValueParameterDescriptor valueParameterDescriptor : callableDescriptor.getValueParameters()) {
|
||||
@@ -123,7 +123,7 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
private static int compiledValueParameterCount(CallableDescriptor callableDescriptor) {
|
||||
if (callableDescriptor.getReceiverParameter().exists()) {
|
||||
if (callableDescriptor.getReceiverParameter() != null) {
|
||||
return 1 + callableDescriptor.getValueParameters().size();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -578,7 +578,7 @@ public class CallResolver {
|
||||
boolean found = false;
|
||||
for (ResolutionCandidate<FunctionDescriptor> resolvedCall : candidates) {
|
||||
FunctionDescriptor functionDescriptor = resolvedCall.getDescriptor();
|
||||
if (functionDescriptor.getReceiverParameter().exists()) continue;
|
||||
if (functionDescriptor.getReceiverParameter() != null) continue;
|
||||
if (!functionDescriptor.getTypeParameters().isEmpty()) continue;
|
||||
if (!checkValueParameters(functionDescriptor, parameterTypes)) continue;
|
||||
result.add(resolvedCall);
|
||||
@@ -593,7 +593,7 @@ public class CallResolver {
|
||||
for (ResolutionCandidate<FunctionDescriptor> candidate : candidates) {
|
||||
FunctionDescriptor functionDescriptor = candidate.getDescriptor();
|
||||
ReceiverParameterDescriptor functionReceiver = functionDescriptor.getReceiverParameter();
|
||||
if (!functionReceiver.exists()) continue;
|
||||
if (functionReceiver == null) continue;
|
||||
if (!functionDescriptor.getTypeParameters().isEmpty()) continue;
|
||||
if (!typeChecker.isSubtypeOf(receiver.getType(), functionReceiver.getType())) continue;
|
||||
if (!checkValueParameters(functionDescriptor, parameterTypes))continue;
|
||||
|
||||
@@ -316,7 +316,7 @@ public class CandidateResolver {
|
||||
// Error is already reported if something is missing
|
||||
ReceiverValue receiverArgument = candidateCall.getReceiverArgument();
|
||||
ReceiverParameterDescriptor receiverParameter = candidateWithFreshVariables.getReceiverParameter();
|
||||
if (receiverArgument.exists() && receiverParameter.exists()) {
|
||||
if (receiverArgument.exists() && receiverParameter != null) {
|
||||
constraintsSystem.addSubtypeConstraint(receiverParameter.getType(), receiverArgument.getType(),
|
||||
ConstraintPosition.RECEIVER_POSITION);
|
||||
}
|
||||
@@ -473,7 +473,7 @@ public class CandidateResolver {
|
||||
BindingContext bindingContext = context.candidateCall.getTrace().getBindingContext();
|
||||
|
||||
ResolutionStatus result = SUCCESS;
|
||||
if (receiverParameter.exists() && receiverArgument.exists()) {
|
||||
if (receiverParameter != null && receiverArgument.exists()) {
|
||||
boolean safeAccess = isExplicitReceiver && !implicitInvokeCheck && candidateCall.isSafeCall();
|
||||
JetType receiverArgumentType = receiverArgument.getType();
|
||||
AutoCastServiceImpl autoCastService = new AutoCastServiceImpl(context.dataFlowInfo, bindingContext);
|
||||
|
||||
+3
-3
@@ -214,11 +214,11 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
|
||||
|
||||
ReceiverParameterDescriptor receiverParameter = candidate.getReceiverParameter();
|
||||
ReceiverValue receiverArgument = candidateCall.getReceiverArgument();
|
||||
if (receiverParameter.exists() &&!receiverArgument.exists()) {
|
||||
if (receiverParameter != null &&!receiverArgument.exists()) {
|
||||
tracing.missingReceiver(traceForCall, receiverParameter);
|
||||
status = ERROR;
|
||||
}
|
||||
if (!receiverParameter.exists() && receiverArgument.exists()) {
|
||||
if (receiverParameter == null && receiverArgument.exists()) {
|
||||
tracing.noReceiverAllowed(traceForCall);
|
||||
if (call.getCalleeExpression() instanceof JetSimpleNameExpression) {
|
||||
status = STRONG_ERROR;
|
||||
@@ -228,7 +228,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
|
||||
}
|
||||
}
|
||||
|
||||
assert (candidateCall.getThisObject().exists() == candidateCall.getResultingDescriptor().getExpectedThisObject().exists()) : "Shouldn't happen because of TaskPrioritizer: " + candidateCall.getCandidateDescriptor();
|
||||
assert (candidateCall.getThisObject().exists() == (candidateCall.getResultingDescriptor().getExpectedThisObject() != null)) : "Shouldn't happen because of TaskPrioritizer: " + candidateCall.getCandidateDescriptor();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ public class OverloadingConflictResolver {
|
||||
|
||||
ReceiverParameterDescriptor receiverOfF = f.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverOfG = g.getReceiverParameter();
|
||||
if (f.getReceiverParameter().exists() && g.getReceiverParameter().exists()) {
|
||||
if (receiverOfF != null && receiverOfG != null) {
|
||||
if (!typeMoreSpecific(receiverOfF.getType(), receiverOfG.getType())) return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ public class CallableDescriptorCollectors {
|
||||
Set<FunctionDescriptor> functions = Sets.newLinkedHashSet(scope.getFunctions(name));
|
||||
for (Iterator<FunctionDescriptor> iterator = functions.iterator(); iterator.hasNext(); ) {
|
||||
FunctionDescriptor functionDescriptor = iterator.next();
|
||||
if (functionDescriptor.getReceiverParameter().exists()) {
|
||||
if (functionDescriptor.getReceiverParameter() != null) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -204,7 +204,7 @@ public abstract class TaskPrioritizer {
|
||||
}
|
||||
if (receiverParameters.size() == 1 && !receiverParameters.iterator().next().exists()) {
|
||||
for (D descriptor : descriptors) {
|
||||
if (descriptor.getExpectedThisObject().exists() && !descriptor.getReceiverParameter().exists()) {
|
||||
if (descriptor.getExpectedThisObject() != null && descriptor.getReceiverParameter() == null) {
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
if (descriptor instanceof ConstructorDescriptor) {
|
||||
assert containingDeclaration != null;
|
||||
@@ -224,7 +224,7 @@ public abstract class TaskPrioritizer {
|
||||
|
||||
private static <D extends CallableDescriptor> boolean setImpliedThis(@NotNull JetScope scope, ResolutionCandidate<D> candidate) {
|
||||
ReceiverParameterDescriptor expectedThisObject = candidate.getDescriptor().getExpectedThisObject();
|
||||
if (!expectedThisObject.exists()) return true;
|
||||
if (expectedThisObject == null) return true;
|
||||
List<ReceiverParameterDescriptor> receivers = scope.getImplicitReceiversHierarchy();
|
||||
for (ReceiverParameterDescriptor receiver : receivers) {
|
||||
if (JetTypeChecker.INSTANCE.isSubtypeOf(receiver.getType(), expectedThisObject.getType())) {
|
||||
|
||||
+2
-2
@@ -264,13 +264,13 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
||||
@Override
|
||||
public List<ReceiverParameterDescriptor> getImplicitReceiversHierarchy() {
|
||||
ReceiverParameterDescriptor receiver = getImplicitReceiver();
|
||||
if (receiver.exists()) {
|
||||
if (receiver != null) {
|
||||
return Collections.singletonList(receiver);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
protected abstract ReceiverParameterDescriptor getImplicitReceiver();
|
||||
|
||||
// Do not change this, override in concrete subclasses:
|
||||
|
||||
@@ -75,7 +75,6 @@ public class LazyPackageMemberScope extends AbstractLazyMemberScope<NamespaceDes
|
||||
.getFileScopeForDeclarationResolution((JetFile) declaration.getContainingFile());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected ReceiverParameterDescriptor getImplicitReceiver() {
|
||||
return ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class JetScopeUtils {
|
||||
for (DeclarationDescriptor descriptor : scope.getAllDescriptors()) {
|
||||
if (descriptor instanceof CallableDescriptor) {
|
||||
CallableDescriptor callDescriptor = (CallableDescriptor) descriptor;
|
||||
if (callDescriptor.getReceiverParameter().exists()) {
|
||||
if (callDescriptor.getReceiverParameter() != null) {
|
||||
result.add(callDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
checkForPropertyRedeclaration(name, variableDescriptor);
|
||||
getPropertyGroups().put(name, variableDescriptor);
|
||||
}
|
||||
if (!variableDescriptor.getReceiverParameter().exists()) {
|
||||
if (variableDescriptor.getReceiverParameter() == null) {
|
||||
checkForRedeclaration(name, variableDescriptor);
|
||||
// TODO : Should this always happen?
|
||||
getVariableClassOrNamespaceDescriptors().put(name, variableDescriptor);
|
||||
@@ -374,7 +374,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
ReceiverParameterDescriptor receiverParameter = variableDescriptor.getReceiverParameter();
|
||||
for (VariableDescriptor oldProperty : properties) {
|
||||
ReceiverParameterDescriptor receiverParameterForOldVariable = oldProperty.getReceiverParameter();
|
||||
if (((receiverParameter.exists() && receiverParameterForOldVariable.exists()) &&
|
||||
if (((receiverParameter != null && receiverParameterForOldVariable != null) &&
|
||||
(JetTypeChecker.INSTANCE.equalTypes(receiverParameter.getType(), receiverParameterForOldVariable.getType())))) {
|
||||
redeclarationHandler.handleRedeclaration(oldProperty, variableDescriptor);
|
||||
}
|
||||
@@ -464,7 +464,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
@Override
|
||||
protected List<ReceiverParameterDescriptor> computeImplicitReceiversHierarchy() {
|
||||
List<ReceiverParameterDescriptor> implicitReceiverHierarchy = Lists.newArrayList();
|
||||
if (implicitReceiver != null && implicitReceiver.exists()) {
|
||||
if (implicitReceiver != null) {
|
||||
implicitReceiverHierarchy.add(implicitReceiver);
|
||||
}
|
||||
implicitReceiverHierarchy.addAll(super.computeImplicitReceiversHierarchy());
|
||||
|
||||
+1
-1
@@ -548,7 +548,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
else if (!receivers.isEmpty()) {
|
||||
result = receivers.get(0);
|
||||
}
|
||||
if (result.exists()) {
|
||||
if (result != NO_RECEIVER_PARAMETER) {
|
||||
context.trace.record(REFERENCE_TARGET, expression.getInstanceReference(), result.getContainingDeclaration());
|
||||
}
|
||||
return LabelResolver.LabeledReceiverResolutionResult.labelResolutionSuccess(result);
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
parameterTypes.add(valueParameter.getType());
|
||||
}
|
||||
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
||||
JetType receiver = receiverParameter.exists() ? receiverParameter.getType() : null;
|
||||
JetType receiver = DescriptorUtils.getReceiverParameterType(receiverParameter);
|
||||
|
||||
JetType returnType = TypeUtils.NO_EXPECTED_TYPE;
|
||||
JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace);
|
||||
|
||||
+2
-2
@@ -234,12 +234,12 @@ public class ExpressionTypingUtils {
|
||||
) {
|
||||
ReceiverParameterDescriptor receiverParameter = callableDescriptor.getReceiverParameter();
|
||||
|
||||
if (!receiverArgument.exists() && !receiverParameter.exists()) {
|
||||
if (!receiverArgument.exists() && receiverParameter == null) {
|
||||
// Both receivers do not exist
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(receiverArgument.exists() && receiverParameter.exists())) {
|
||||
if (!(receiverArgument.exists() && receiverParameter != null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ public class LabelResolver {
|
||||
DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, element);
|
||||
if (declarationDescriptor instanceof FunctionDescriptor) {
|
||||
ReceiverParameterDescriptor thisReceiver = ((FunctionDescriptor) declarationDescriptor).getReceiverParameter();
|
||||
if (thisReceiver.exists()) {
|
||||
if (thisReceiver != null) {
|
||||
context.trace.record(LABEL_TARGET, targetLabel, element);
|
||||
context.trace.record(REFERENCE_TARGET, thisReference, declarationDescriptor);
|
||||
}
|
||||
@@ -177,8 +177,8 @@ public class LabelResolver {
|
||||
}
|
||||
|
||||
public static final class LabeledReceiverResolutionResult {
|
||||
public static LabeledReceiverResolutionResult labelResolutionSuccess(@NotNull ReceiverParameterDescriptor receiverParameterDescriptor) {
|
||||
if (!receiverParameterDescriptor.exists()) {
|
||||
public static LabeledReceiverResolutionResult labelResolutionSuccess(@Nullable ReceiverParameterDescriptor receiverParameterDescriptor) {
|
||||
if (receiverParameterDescriptor == null) {
|
||||
return new LabeledReceiverResolutionResult(Code.NO_THIS, null);
|
||||
}
|
||||
return new LabeledReceiverResolutionResult(Code.SUCCESS, receiverParameterDescriptor);
|
||||
|
||||
@@ -354,7 +354,7 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
@NotNull StringBuilder builder,
|
||||
@Nullable Boolean isVar,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull ReceiverParameterDescriptor receiver,
|
||||
@Nullable ReceiverParameterDescriptor receiver,
|
||||
@Nullable JetType outType) {
|
||||
String typeString = lt() + "no type>";
|
||||
if (outType != null) {
|
||||
@@ -366,7 +366,7 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
|
||||
renderTypeParameters(typeParameters, builder);
|
||||
|
||||
if (receiver.exists()) {
|
||||
if (receiver != null) {
|
||||
builder.append(escape(renderType(receiver.getType()))).append(".");
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
}
|
||||
|
||||
ReceiverParameterDescriptor receiver = descriptor.getReceiverParameter();
|
||||
if (receiver.exists()) {
|
||||
if (receiver != null) {
|
||||
builder.append(escape(renderType(receiver.getType()))).append(".");
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
@@ -431,7 +430,7 @@ public class NamespaceComparator {
|
||||
}
|
||||
|
||||
private void serializeReceiver(CallableDescriptor fun) {
|
||||
if (fun.getReceiverParameter().exists()) {
|
||||
if (fun.getReceiverParameter() != null) {
|
||||
new TypeSerializer(sb).serialize(fun.getReceiverParameter());
|
||||
sb.append(".");
|
||||
}
|
||||
@@ -492,8 +491,9 @@ public class NamespaceComparator {
|
||||
sb.append("> ");
|
||||
}
|
||||
sb.append("!");
|
||||
if (prop.getReceiverParameter().exists()) {
|
||||
new TypeSerializer(sb).serialize(prop.getReceiverParameter().getType());
|
||||
ReceiverParameterDescriptor receiverParameter = prop.getReceiverParameter();
|
||||
if (receiverParameter != null) {
|
||||
new TypeSerializer(sb).serialize(receiverParameter.getType());
|
||||
sb.append(".");
|
||||
}
|
||||
sb.append(prop.getName());
|
||||
|
||||
@@ -77,7 +77,7 @@ public final class JetDescriptorIconProvider {
|
||||
}
|
||||
if (descriptor instanceof FunctionDescriptor) {
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
if (functionDescriptor.getReceiverParameter().exists()) {
|
||||
if (functionDescriptor.getReceiverParameter() != null) {
|
||||
return JetIcons.EXTENSION_FUNCTION;
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
||||
|
||||
private static void addReceiverParameter(CallableDescriptor descriptor, StringBuilder bodyBuilder) {
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
|
||||
if (receiverParameter.exists()) {
|
||||
if (receiverParameter != null) {
|
||||
bodyBuilder.append(receiverParameter.getType()).append(".");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public final class DescriptorLookupConverter {
|
||||
typeText = DescriptorRenderer.TEXT.renderType(returnType);
|
||||
presentableText += DescriptorRenderer.TEXT.renderFunctionParameters(functionDescriptor);
|
||||
|
||||
boolean extensionFunction = functionDescriptor.getReceiverParameter().exists();
|
||||
boolean extensionFunction = functionDescriptor.getReceiverParameter() != null;
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
if (containingDeclaration != null && extensionFunction) {
|
||||
tailText += " for " + DescriptorRenderer.TEXT.renderType(functionDescriptor.getReceiverParameter().getType());
|
||||
|
||||
@@ -184,7 +184,7 @@ public class JetFunctionInsertHandler implements InsertHandler<LookupElement> {
|
||||
final SimpleFunctionDescriptor functionDescriptor = (SimpleFunctionDescriptor) descriptor;
|
||||
// Don't insert import for qualified expression if don't try to insert extension function
|
||||
if (PsiTreeUtil.getParentOfType(element, JetQualifiedExpression.class) != null &&
|
||||
!functionDescriptor.getReceiverParameter().exists()) {
|
||||
functionDescriptor.getReceiverParameter() == null) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ package org.jetbrains.jet.plugin.highlighter;
|
||||
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
|
||||
@@ -75,7 +72,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
|
||||
if (fun.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.NAMESPACE_FUNCTION_CALL);
|
||||
}
|
||||
if (fun.getReceiverParameter().exists()) {
|
||||
if (fun.getReceiverParameter() != null) {
|
||||
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.EXTENSION_FUNCTION_CALL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters1;
|
||||
@@ -140,8 +141,9 @@ public class IdeRenderers {
|
||||
Set<ValueParameterDescriptor> parametersToHighlight = getParametersToHighlight(call);
|
||||
|
||||
DescriptorRenderer htmlRenderer = DescriptorRenderer.HTML;
|
||||
if (funDescriptor.getReceiverParameter().exists()) {
|
||||
stringBuilder.append(htmlRenderer.renderType(funDescriptor.getReceiverParameter().getType())).append(".");
|
||||
ReceiverParameterDescriptor receiverParameter = funDescriptor.getReceiverParameter();
|
||||
if (receiverParameter != null) {
|
||||
stringBuilder.append(htmlRenderer.renderType(receiverParameter.getType())).append(".");
|
||||
}
|
||||
stringBuilder.append(funDescriptor.getName()).append("(");
|
||||
boolean first = true;
|
||||
|
||||
@@ -19,10 +19,7 @@ package org.jetbrains.jet.plugin.highlighter;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.JetParameter;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||
@@ -84,7 +81,7 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
JetPsiChecker.highlightName(holder, elementToHighlight,
|
||||
namespace ? JetHighlightingColors.NAMESPACE_PROPERTY : JetHighlightingColors.INSTANCE_PROPERTY
|
||||
);
|
||||
if (descriptor.getReceiverParameter().exists()) {
|
||||
if (descriptor.getReceiverParameter() != null) {
|
||||
JetPsiChecker.highlightName(holder, elementToHighlight, JetHighlightingColors.EXTENSION_PROPERTY);
|
||||
}
|
||||
if (withBackingField) {
|
||||
|
||||
@@ -35,7 +35,7 @@ class DeclarationDescriptorComparator implements Comparator<DeclarationDescripto
|
||||
}
|
||||
else if (descriptor instanceof FunctionDescriptor) {
|
||||
FunctionDescriptor fun = (FunctionDescriptor)descriptor;
|
||||
if (!fun.getReceiverParameter().exists()) {
|
||||
if (fun.getReceiverParameter() == null) {
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
@@ -64,9 +64,11 @@ class DeclarationDescriptorComparator implements Comparator<DeclarationDescripto
|
||||
CallableDescriptor c1 = (CallableDescriptor)o1;
|
||||
CallableDescriptor c2 = (CallableDescriptor)o2;
|
||||
|
||||
if (c1.getReceiverParameter().exists() && c2.getReceiverParameter().exists()) {
|
||||
String r1 = DescriptorRenderer.TEXT.renderType(c1.getReceiverParameter().getType());
|
||||
String r2 = DescriptorRenderer.TEXT.renderType(c2.getReceiverParameter().getType());
|
||||
ReceiverParameterDescriptor c1ReceiverParameter = c1.getReceiverParameter();
|
||||
ReceiverParameterDescriptor c2ReceiverParameter = c2.getReceiverParameter();
|
||||
if (c1ReceiverParameter != null && c2ReceiverParameter != null) {
|
||||
String r1 = DescriptorRenderer.TEXT.renderType(c1ReceiverParameter.getType());
|
||||
String r2 = DescriptorRenderer.TEXT.renderType(c2ReceiverParameter.getType());
|
||||
int receiversCompareTo = r1.compareTo(r2);
|
||||
if (receiversCompareTo != 0) {
|
||||
return receiversCompareTo;
|
||||
|
||||
@@ -164,7 +164,7 @@ public class JetSourceNavigationHelper {
|
||||
if (receiverType == null) {
|
||||
// non-extension property
|
||||
for (Descr candidate : matcher.getCandidatesFromScope(namespaceDescriptor.getMemberScope(), entityNameAsName)) {
|
||||
if (!candidate.getReceiverParameter().exists()) {
|
||||
if (candidate.getReceiverParameter() == null) {
|
||||
if (matcher.areSame(decompiledDeclaration, candidate)) {
|
||||
return (JetDeclaration) BindingContextUtils.descriptorToDeclaration(bindingContext, candidate);
|
||||
}
|
||||
@@ -175,8 +175,9 @@ public class JetSourceNavigationHelper {
|
||||
// extension property
|
||||
String expectedTypeString = receiverType.getText();
|
||||
for (Descr candidate : matcher.getCandidatesFromScope(namespaceDescriptor.getMemberScope(), entityNameAsName)) {
|
||||
if (candidate.getReceiverParameter().exists()) {
|
||||
String thisReceiverType = DescriptorRenderer.TEXT.renderType(candidate.getReceiverParameter().getType());
|
||||
ReceiverParameterDescriptor receiverParameter = candidate.getReceiverParameter();
|
||||
if (receiverParameter != null) {
|
||||
String thisReceiverType = DescriptorRenderer.TEXT.renderType(receiverParameter.getType());
|
||||
if (expectedTypeString.equals(thisReceiverType)) {
|
||||
if (matcher.areSame(decompiledDeclaration, candidate)) {
|
||||
return (JetDeclaration) BindingContextUtils.descriptorToDeclaration(bindingContext, candidate);
|
||||
|
||||
@@ -195,7 +195,7 @@ public class JetStructureViewElement implements StructureViewTreeElement {
|
||||
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
ReceiverParameterDescriptor receiver = functionDescriptor.getReceiverParameter();
|
||||
if (receiver.exists()) {
|
||||
if (receiver != null) {
|
||||
textBuilder.append(DescriptorRenderer.TEXT.renderType(receiver.getType())).append(".");
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ public final class StaticContext {
|
||||
|
||||
boolean isGetter = descriptor instanceof PropertyGetterDescriptor;
|
||||
String accessorName = Namer.getNameForAccessor(propertyName, isGetter,
|
||||
!accessorDescriptor.getReceiverParameter().exists() && isEcma5());
|
||||
accessorDescriptor.getReceiverParameter() == null && isEcma5());
|
||||
return declareName(descriptor, accessorName);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ class InnerFunctionTranslator extends InnerDeclarationTranslator {
|
||||
@NotNull
|
||||
private JsExpression getThis() {
|
||||
ClassDescriptor outerClassDescriptor = closureContext.outerClassDescriptor;
|
||||
if (outerClassDescriptor != null && !descriptor.getReceiverParameter().exists()) {
|
||||
if (outerClassDescriptor != null && descriptor.getReceiverParameter() == null) {
|
||||
return JsLiteral.THIS;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionCandidate;
|
||||
@@ -107,8 +108,8 @@ public final class CallBuilder {
|
||||
private CallTranslator finish() {
|
||||
if (resolvedCall == null) {
|
||||
assert descriptor != null;
|
||||
resolvedCall = ResolvedCallImpl.create(ResolutionCandidate.create(descriptor, descriptor.getExpectedThisObject().getValue(),
|
||||
descriptor.getReceiverParameter().getValue(),
|
||||
resolvedCall = ResolvedCallImpl.create(ResolutionCandidate.create(descriptor, DescriptorUtils.safeGetValue(descriptor.getExpectedThisObject()),
|
||||
DescriptorUtils.safeGetValue(descriptor.getReceiverParameter()),
|
||||
ExplicitReceiverKind.THIS_OBJECT, false),
|
||||
TemporaryBindingTrace.create(new BindingTraceContext(), "trace to resolve call (in js)"));
|
||||
}
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ public final class NativePropertyAccessTranslator extends PropertyAccessTranslat
|
||||
if (receiver != null) {
|
||||
return receiver;
|
||||
}
|
||||
assert !propertyDescriptor.getReceiverParameter().exists() : "Can't have native extension properties.";
|
||||
assert propertyDescriptor.getReceiverParameter() == null : "Can't have native extension properties.";
|
||||
DeclarationDescriptor expectedThisDescriptor = getExpectedThisDescriptor(propertyDescriptor);
|
||||
if (expectedThisDescriptor == null) {
|
||||
return null;
|
||||
|
||||
@@ -85,14 +85,14 @@ public final class JsDescriptorUtils {
|
||||
}
|
||||
|
||||
public static boolean isExtension(@NotNull CallableDescriptor functionDescriptor) {
|
||||
return (functionDescriptor.getReceiverParameter().exists());
|
||||
return (functionDescriptor.getReceiverParameter() != null);
|
||||
}
|
||||
|
||||
//TODO: why callable descriptor
|
||||
@Nullable
|
||||
public static DeclarationDescriptor getExpectedThisDescriptor(@NotNull CallableDescriptor callableDescriptor) {
|
||||
ReceiverParameterDescriptor expectedThisObject = callableDescriptor.getExpectedThisObject();
|
||||
if (!expectedThisObject.exists()) {
|
||||
if (expectedThisObject == null) {
|
||||
return null;
|
||||
}
|
||||
return getDeclarationDescriptorForReceiver(expectedThisObject.getValue());
|
||||
@@ -111,7 +111,7 @@ public final class JsDescriptorUtils {
|
||||
@Nullable
|
||||
public static DeclarationDescriptor getExpectedReceiverDescriptor(@NotNull CallableDescriptor callableDescriptor) {
|
||||
ReceiverParameterDescriptor receiverParameter = callableDescriptor.getReceiverParameter();
|
||||
if (!receiverParameter.exists()) {
|
||||
if (receiverParameter == null) {
|
||||
return null;
|
||||
}
|
||||
return getDeclarationDescriptorForReceiver(receiverParameter.getValue());
|
||||
|
||||
@@ -388,8 +388,8 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
||||
val name = descriptor.getName().getName()
|
||||
val returnType = getType(descriptor.getReturnType())
|
||||
if (returnType != null) {
|
||||
val receiver = descriptor.getReceiverParameter().getValue()
|
||||
val extensionClass = if (receiver is ExtensionReceiver) {
|
||||
val receiver = descriptor.getReceiverParameter()
|
||||
val extensionClass = if (receiver != null) {
|
||||
getType(receiver.getType())
|
||||
} else null
|
||||
|
||||
@@ -427,8 +427,8 @@ class KModel(val context: BindingContext, val config: KDocConfig, val sourceDirs
|
||||
val function = KFunction(descriptor, owner, name, returnType, parameters)
|
||||
addTypeParameters(function.typeParameters, descriptor.getTypeParameters())
|
||||
configureComments(function, descriptor)
|
||||
val receiver = descriptor.getReceiverParameter().getValue()
|
||||
if (receiver is ExtensionReceiver) {
|
||||
val receiver = descriptor.getReceiverParameter()
|
||||
if (receiver != null) {
|
||||
val receiverType = getType(receiver.getType())
|
||||
function.receiverType = receiverType
|
||||
function.extensionClass = receiverType?.klass
|
||||
|
||||
Reference in New Issue
Block a user