Migrating descriptors onto ReceiverParameterDescriptor
This commit is contained in:
@@ -19,10 +19,11 @@ 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.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
@@ -35,7 +36,7 @@ public class AccessorForFunctionDescriptor extends SimpleFunctionDescriptorImpl
|
||||
FunctionDescriptor fd = (FunctionDescriptor) descriptor;
|
||||
|
||||
initialize(fd.getReceiverParameter().exists() ? fd.getReceiverParameter().getType() : null,
|
||||
descriptor instanceof ConstructorDescriptor ? ReceiverDescriptor.NO_RECEIVER : fd.getExpectedThisObject(),
|
||||
descriptor instanceof ConstructorDescriptor ? NO_RECEIVER_PARAMETER : fd.getExpectedThisObject(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
fd.getValueParameters(),
|
||||
fd.getReturnType(),
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -174,7 +173,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
|
||||
iv.load(0, Type.getObjectType(className));
|
||||
|
||||
final ReceiverDescriptor receiver = funDescriptor.getReceiverParameter();
|
||||
final ReceiverParameterDescriptor receiver = funDescriptor.getReceiverParameter();
|
||||
int count = 1;
|
||||
if (receiver.exists()) {
|
||||
StackValue.local(count, OBJECT_TYPE).put(OBJECT_TYPE, iv);
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.*;
|
||||
@@ -147,7 +146,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
MethodBounds methodBounds = generateMethodBody(mv, fun, functionDescriptor, context, asmMethod, localVariablesInfo);
|
||||
|
||||
Type thisType;
|
||||
ReceiverDescriptor expectedThisObject = functionDescriptor.getExpectedThisObject();
|
||||
ReceiverParameterDescriptor expectedThisObject = functionDescriptor.getExpectedThisObject();
|
||||
if (expectedThisObject.exists()) {
|
||||
thisType = typeMapper.mapType(expectedThisObject.getType());
|
||||
}
|
||||
@@ -396,7 +395,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
|
||||
List<ValueParameterDescriptor> paramDescrs = functionDescriptor.getValueParameters();
|
||||
Modality modality = functionDescriptor.getModality();
|
||||
ReceiverDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
||||
|
||||
int start = 0;
|
||||
if (functionDescriptor instanceof PropertyAccessorDescriptor) {
|
||||
@@ -546,7 +545,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
return;
|
||||
}
|
||||
|
||||
ReceiverDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
||||
boolean hasReceiver = receiverParameter.exists();
|
||||
boolean isStatic = isStatic(kind);
|
||||
|
||||
@@ -592,7 +591,7 @@ public class FunctionCodegen extends GenerationStateAware {
|
||||
Method jvmSignature,
|
||||
FunctionDescriptor functionDescriptor,
|
||||
OwnerKind kind,
|
||||
ReceiverDescriptor receiverParameter,
|
||||
ReceiverParameterDescriptor receiverParameter,
|
||||
boolean hasReceiver,
|
||||
boolean aStatic,
|
||||
JvmClassName ownerInternalName,
|
||||
|
||||
@@ -1331,7 +1331,7 @@ public abstract class StackValue {
|
||||
|
||||
private void genReceiver(
|
||||
InstructionAdapter v, ReceiverDescriptor receiverArgument, Type type,
|
||||
@Nullable ReceiverDescriptor receiverParameter, int depth
|
||||
@Nullable ReceiverParameterDescriptor receiverParameter, int depth
|
||||
) {
|
||||
if (receiver == StackValue.none()) {
|
||||
if (receiverParameter != null) {
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
@@ -500,7 +499,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
|
||||
writeFormalTypeParameters(f.getTypeParameters(), signatureVisitor);
|
||||
|
||||
final ReceiverDescriptor receiverTypeRef = f.getReceiverParameter();
|
||||
final ReceiverParameterDescriptor receiverTypeRef = f.getReceiverParameter();
|
||||
final JetType receiverType = !receiverTypeRef.exists() ? null : receiverTypeRef.getType();
|
||||
final List<ValueParameterDescriptor> parameters = f.getValueParameters();
|
||||
|
||||
@@ -611,7 +610,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
}
|
||||
|
||||
public JvmMethodSignature mapSignature(Name name, FunctionDescriptor f) {
|
||||
final ReceiverDescriptor receiver = f.getReceiverParameter();
|
||||
final ReceiverParameterDescriptor receiver = f.getReceiverParameter();
|
||||
|
||||
BothSignatureWriter signatureWriter = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD, false);
|
||||
|
||||
@@ -638,7 +637,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
||||
return signatureWriter.makeJvmMethodSignature(name.getName());
|
||||
}
|
||||
|
||||
private void writeReceiverIfNeeded(ReceiverDescriptor receiver, BothSignatureWriter signatureWriter) {
|
||||
private void writeReceiverIfNeeded(ReceiverParameterDescriptor receiver, BothSignatureWriter signatureWriter) {
|
||||
if (receiver.exists()) {
|
||||
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
||||
mapType(receiver.getType(), signatureWriter, JetTypeMapperMode.VALUE);
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
@@ -30,10 +29,10 @@ import java.util.Set;
|
||||
*/
|
||||
public interface CallableDescriptor extends DeclarationDescriptorWithVisibility, DeclarationDescriptorNonRoot {
|
||||
@NotNull
|
||||
ReceiverDescriptor getReceiverParameter();
|
||||
ReceiverParameterDescriptor getReceiverParameter();
|
||||
|
||||
@NotNull
|
||||
ReceiverDescriptor getExpectedThisObject();
|
||||
ReceiverParameterDescriptor getExpectedThisObject();
|
||||
|
||||
@NotNull
|
||||
List<TypeParameterDescriptor> getTypeParameters();
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
@@ -75,5 +74,5 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor,
|
||||
Visibility getVisibility();
|
||||
|
||||
@NotNull
|
||||
ReceiverDescriptor getImplicitReceiver();
|
||||
ReceiverParameterDescriptor getThisAsReceiverParameter();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -40,7 +39,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorNonRootImpl implem
|
||||
private JetScope memberDeclarations;
|
||||
private Set<ConstructorDescriptor> constructors;
|
||||
private ConstructorDescriptor primaryConstructor;
|
||||
private ReceiverDescriptor implicitReceiver;
|
||||
private ReceiverParameterDescriptor thisAsReceiverParameter;
|
||||
private final Modality modality;
|
||||
private ClassDescriptor classObjectDescriptor;
|
||||
private final ClassKind kind;
|
||||
@@ -171,11 +170,11 @@ public class ClassDescriptorImpl extends DeclarationDescriptorNonRootImpl implem
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getImplicitReceiver() {
|
||||
if (implicitReceiver == null) {
|
||||
implicitReceiver = new ClassReceiver(this);
|
||||
public ReceiverParameterDescriptor getThisAsReceiverParameter() {
|
||||
if (thisAsReceiverParameter == null) {
|
||||
thisAsReceiverParameter = new ReceiverParameterDescriptorImpl(this, getDefaultType());
|
||||
}
|
||||
return implicitReceiver;
|
||||
return thisAsReceiverParameter;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+4
-3
@@ -20,12 +20,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
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.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
@@ -51,12 +52,12 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
|
||||
|
||||
//isStatic - for java only
|
||||
public ConstructorDescriptorImpl initialize(@NotNull List<TypeParameterDescriptor> typeParameters, @NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters, Visibility visibility, boolean isStatic) {
|
||||
super.initialize(null, isStatic ? ReceiverDescriptor.NO_RECEIVER : getExpectedThisObject(getContainingDeclaration()), typeParameters, unsubstitutedValueParameters, null, Modality.FINAL, visibility);
|
||||
super.initialize(null, isStatic ? NO_RECEIVER_PARAMETER : getExpectedThisObject(getContainingDeclaration()), typeParameters, unsubstitutedValueParameters, null, Modality.FINAL, visibility);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static ReceiverDescriptor getExpectedThisObject(@NotNull ClassDescriptor descriptor) {
|
||||
private static ReceiverParameterDescriptor getExpectedThisObject(@NotNull ClassDescriptor descriptor) {
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
return DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration);
|
||||
}
|
||||
|
||||
+5
@@ -92,4 +92,9 @@ public class DeclarationDescriptorVisitorEmptyBodies<R, D> implements Declaratio
|
||||
public R visitPropertySetterDescriptor(PropertySetterDescriptor descriptor, D data) {
|
||||
return visitPropertyAccessorDescriptor(descriptor, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R visitReceiverParameterDescriptor(ReceiverParameterDescriptor descriptor, D data) {
|
||||
return visitDeclarationDescriptor(descriptor, data);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-17
@@ -23,9 +23,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.jet.lang.types.DescriptorSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
@@ -34,7 +31,7 @@ import org.jetbrains.jet.lang.types.Variance;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor.NO_RECEIVER;
|
||||
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -44,8 +41,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
protected List<TypeParameterDescriptor> typeParameters;
|
||||
protected List<ValueParameterDescriptor> unsubstitutedValueParameters;
|
||||
protected JetType unsubstitutedReturnType;
|
||||
private ReceiverDescriptor receiverParameter;
|
||||
protected ReceiverDescriptor expectedThisObject;
|
||||
private ReceiverParameterDescriptor receiverParameter;
|
||||
protected ReceiverParameterDescriptor expectedThisObject;
|
||||
|
||||
protected Modality modality;
|
||||
protected Visibility visibility;
|
||||
@@ -76,7 +73,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
protected FunctionDescriptorImpl initialize(
|
||||
@Nullable JetType receiverParameterType,
|
||||
@NotNull ReceiverDescriptor expectedThisObject,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable JetType unsubstitutedReturnType,
|
||||
@@ -87,7 +84,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
this.unsubstitutedReturnType = unsubstitutedReturnType;
|
||||
this.modality = modality;
|
||||
this.visibility = visibility;
|
||||
this.receiverParameter = receiverParameterType == null ? NO_RECEIVER : new ExtensionReceiver(this, receiverParameterType);
|
||||
this.receiverParameter = receiverParameterType == null ? NO_RECEIVER_PARAMETER : new ReceiverParameterDescriptorImpl(this, receiverParameterType);
|
||||
this.expectedThisObject = expectedThisObject;
|
||||
|
||||
for (int i = 0; i < typeParameters.size(); ++i) {
|
||||
@@ -123,13 +120,13 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getReceiverParameter() {
|
||||
public ReceiverParameterDescriptor getReceiverParameter() {
|
||||
return receiverParameter;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getExpectedThisObject() {
|
||||
public ReceiverParameterDescriptor getExpectedThisObject() {
|
||||
return expectedThisObject;
|
||||
}
|
||||
|
||||
@@ -207,13 +204,9 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
}
|
||||
}
|
||||
|
||||
ReceiverDescriptor substitutedExpectedThis = NO_RECEIVER;
|
||||
if (expectedThisObject.exists()) {
|
||||
JetType substitutedType = substitutor.substitute(expectedThisObject.getType(), Variance.INVARIANT);
|
||||
if (substitutedType == null) {
|
||||
return null;
|
||||
}
|
||||
substitutedExpectedThis = new TransientReceiver(substitutedType);
|
||||
ReceiverParameterDescriptor substitutedExpectedThis = expectedThisObject.substitute(substitutor);
|
||||
if (substitutedExpectedThis == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ValueParameterDescriptor> substitutedValueParameters = FunctionDescriptorUtil.getSubstitutedValueParameters(substitutedDescriptor, this, substitutor);
|
||||
|
||||
+2
-2
@@ -105,7 +105,7 @@ public class FunctionDescriptorUtil {
|
||||
@NotNull
|
||||
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");
|
||||
ReceiverDescriptor receiver = descriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiver = descriptor.getReceiverParameter();
|
||||
if (receiver.exists()) {
|
||||
parameterScope.setImplicitReceiver(receiver);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class FunctionDescriptorUtil {
|
||||
return parameterScope;
|
||||
}
|
||||
|
||||
public static void initializeFromFunctionType(@NotNull FunctionDescriptorImpl functionDescriptor, @NotNull JetType functionType, @NotNull ReceiverDescriptor expectedThisObject,
|
||||
public static void initializeFromFunctionType(@NotNull FunctionDescriptorImpl functionDescriptor, @NotNull JetType functionType, @NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull Modality modality, @NotNull Visibility visibility) {
|
||||
|
||||
assert KotlinBuiltIns.getInstance().isFunctionType(functionType);
|
||||
|
||||
+1
-4
@@ -17,18 +17,15 @@
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -107,7 +104,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getImplicitReceiver() {
|
||||
public ReceiverParameterDescriptor getThisAsReceiverParameter() {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -248,7 +248,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite implement
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getImplicitReceiver() {
|
||||
return classObjectDescriptor.getImplicitReceiver();
|
||||
return classObjectDescriptor.getThisAsReceiverParameter();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
+3
-4
@@ -25,7 +25,6 @@ import org.jetbrains.jet.lang.resolve.scopes.InnerClassesScopeWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
@@ -56,7 +55,7 @@ public abstract class MutableClassDescriptorLite extends ClassDescriptorBase {
|
||||
private JetScope scopeForMemberLookup;
|
||||
private JetScope innerClassesScope;
|
||||
|
||||
private ClassReceiver implicitReceiver;
|
||||
private ReceiverParameterDescriptor implicitReceiver;
|
||||
|
||||
private Name name;
|
||||
private final DeclarationDescriptor containingDeclaration;
|
||||
@@ -231,9 +230,9 @@ public abstract class MutableClassDescriptorLite extends ClassDescriptorBase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getImplicitReceiver() {
|
||||
public ReceiverParameterDescriptor getThisAsReceiverParameter() {
|
||||
if (implicitReceiver == null) {
|
||||
implicitReceiver = new ClassReceiver(this);
|
||||
implicitReceiver = new ReceiverParameterDescriptorImpl(this, getDefaultType());
|
||||
}
|
||||
return implicitReceiver;
|
||||
}
|
||||
|
||||
+2
-3
@@ -20,7 +20,6 @@ import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -109,13 +108,13 @@ public abstract class PropertyAccessorDescriptor extends DeclarationDescriptorNo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getReceiverParameter() {
|
||||
public ReceiverParameterDescriptor getReceiverParameter() {
|
||||
return getCorrespondingProperty().getReceiverParameter();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getExpectedThisObject() {
|
||||
public ReceiverParameterDescriptor getExpectedThisObject() {
|
||||
return getCorrespondingProperty().getExpectedThisObject();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,6 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver;
|
||||
import org.jetbrains.jet.lang.types.DescriptorSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
@@ -36,7 +33,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor.NO_RECEIVER;
|
||||
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -50,8 +47,8 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
private final PropertyDescriptor original;
|
||||
private final Kind kind;
|
||||
|
||||
private ReceiverDescriptor expectedThisObject;
|
||||
private ReceiverDescriptor receiver;
|
||||
private ReceiverParameterDescriptor expectedThisObject;
|
||||
private ReceiverParameterDescriptor receiverParameter;
|
||||
private List<TypeParameterDescriptor> typeParameters;
|
||||
private PropertyGetterDescriptor getter;
|
||||
private PropertySetterDescriptor setter;
|
||||
@@ -93,7 +90,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
@NotNull Visibility visibility,
|
||||
boolean isVar,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull ReceiverDescriptor expectedThisObject,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull Name name,
|
||||
@NotNull JetType outType,
|
||||
@NotNull Kind kind
|
||||
@@ -102,19 +99,29 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
setType(outType, Collections.<TypeParameterDescriptor>emptyList(), expectedThisObject, receiverType);
|
||||
}
|
||||
|
||||
public void setType(@NotNull JetType outType, @NotNull List<? extends TypeParameterDescriptor> typeParameters, @NotNull ReceiverDescriptor expectedThisObject, @Nullable JetType receiverType) {
|
||||
ReceiverDescriptor receiver = receiverType == null
|
||||
? NO_RECEIVER
|
||||
: new ExtensionReceiver(this, receiverType);
|
||||
setType(outType, typeParameters, expectedThisObject, receiver);
|
||||
public void setType(
|
||||
@NotNull JetType outType,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@Nullable JetType receiverType
|
||||
) {
|
||||
ReceiverParameterDescriptor receiverParameter = receiverType == null
|
||||
? NO_RECEIVER_PARAMETER
|
||||
: new ReceiverParameterDescriptorImpl(this, receiverType);
|
||||
setType(outType, typeParameters, expectedThisObject, receiverParameter);
|
||||
}
|
||||
|
||||
public void setType(@NotNull JetType outType, @NotNull List<? extends TypeParameterDescriptor> typeParameters, @NotNull ReceiverDescriptor expectedThisObject, @NotNull ReceiverDescriptor receiver) {
|
||||
public void setType(
|
||||
@NotNull JetType outType,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull ReceiverParameterDescriptor receiverParameter
|
||||
) {
|
||||
setOutType(outType);
|
||||
|
||||
this.typeParameters = Lists.newArrayList(typeParameters);
|
||||
|
||||
this.receiver = receiver;
|
||||
this.receiverParameter = receiverParameter;
|
||||
this.expectedThisObject = expectedThisObject;
|
||||
}
|
||||
|
||||
@@ -135,13 +142,13 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ReceiverDescriptor getReceiverParameter() {
|
||||
return receiver;
|
||||
public ReceiverParameterDescriptor getReceiverParameter() {
|
||||
return receiverParameter;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getExpectedThisObject() {
|
||||
public ReceiverParameterDescriptor getExpectedThisObject() {
|
||||
return expectedThisObject;
|
||||
}
|
||||
|
||||
@@ -212,18 +219,11 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
||||
return null; // TODO : tell the user that the property was projected out
|
||||
}
|
||||
|
||||
ReceiverDescriptor substitutedExpectedThisObject;
|
||||
if (expectedThisObject.exists()) {
|
||||
JetType substitutedExpectedThisObjectType = substitutor.substitute(getExpectedThisObject().getType(), Variance.INVARIANT);
|
||||
substitutedExpectedThisObject = new TransientReceiver(substitutedExpectedThisObjectType);
|
||||
}
|
||||
else {
|
||||
substitutedExpectedThisObject = NO_RECEIVER;
|
||||
}
|
||||
ReceiverParameterDescriptor substitutedExpectedThisObject = getExpectedThisObject().substitute(substitutor);
|
||||
|
||||
JetType substitutedReceiverType;
|
||||
if (receiver.exists()) {
|
||||
substitutedReceiverType = substitutor.substitute(receiver.getType(), Variance.IN_VARIANCE);
|
||||
if (receiverParameter.exists()) {
|
||||
substitutedReceiverType = substitutor.substitute(receiverParameter.getType(), Variance.IN_VARIANCE);
|
||||
if (substitutedReceiverType == null) return null;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.descriptors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -36,7 +35,7 @@ public class ScriptCodeDescriptor extends FunctionDescriptorImpl {
|
||||
}
|
||||
|
||||
public void initialize(
|
||||
@NotNull ReceiverDescriptor expectedThisObject,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull JetType returnType) {
|
||||
super.initialize(null, expectedThisObject, Collections.<TypeParameterDescriptor>emptyList(), valueParameters, returnType, Modality.FINAL, Visibilities.LOCAL);
|
||||
|
||||
@@ -29,9 +29,6 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ScriptReceiver;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
@@ -52,13 +49,15 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl {
|
||||
private List<ValueParameterDescriptor> valueParameters;
|
||||
|
||||
private final ScriptCodeDescriptor scriptCodeDescriptor = new ScriptCodeDescriptor(this);
|
||||
private final ReceiverDescriptor implicitReceiver = new ScriptReceiver(this);
|
||||
private final ReceiverParameterDescriptor implicitReceiver = new ReceiverParameterDescriptorImpl(this,
|
||||
// Putting Any here makes no sense,
|
||||
// it is simply copied from someplace else
|
||||
// during a refactoring
|
||||
KotlinBuiltIns.getInstance().getAnyType());
|
||||
|
||||
private ClassDescriptorImpl classDescriptor;
|
||||
private final ClassDescriptorImpl classDescriptor;
|
||||
|
||||
private WritableScopeImpl classScope;
|
||||
private ClassDescriptorImpl descriptor;
|
||||
private ClassReceiver classReceiver;
|
||||
private final WritableScopeImpl classScope;
|
||||
|
||||
public ScriptDescriptor(@Nullable DeclarationDescriptor containingDeclaration, int priority, JetScript script, JetScope scriptScope) {
|
||||
super(containingDeclaration, Collections.<AnnotationDescriptor>emptyList(), NAME);
|
||||
@@ -80,7 +79,6 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl {
|
||||
classScope,
|
||||
new HashSet<ConstructorDescriptor>(),
|
||||
null);
|
||||
classReceiver = new ClassReceiver(classDescriptor);
|
||||
}
|
||||
|
||||
public void initialize(@NotNull JetType returnType, JetScript declaration, BindingContext bindingContext) {
|
||||
@@ -94,7 +92,11 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl {
|
||||
false,
|
||||
Name.identifier(ScriptNameUtil.LAST_EXPRESSION_VALUE_FIELD_NAME),
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
propertyDescriptor.setType(returnType, Collections.<TypeParameterDescriptor>emptyList(), new ClassReceiver(classDescriptor), ReceiverDescriptor.NO_RECEIVER);
|
||||
propertyDescriptor.setType(
|
||||
returnType,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
classDescriptor.getThisAsReceiverParameter(),
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER);
|
||||
propertyDescriptor.initialize(null, null);
|
||||
classScope.addPropertyDescriptor(propertyDescriptor);
|
||||
|
||||
@@ -150,7 +152,7 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ReceiverDescriptor getImplicitReceiver() {
|
||||
public ReceiverParameterDescriptor getThisAsReceiverParameter() {
|
||||
return implicitReceiver;
|
||||
}
|
||||
|
||||
@@ -182,7 +184,10 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl {
|
||||
false,
|
||||
parameter.getName(),
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
propertyDescriptor.setType(parameter.getType(), Collections.<TypeParameterDescriptor>emptyList(), classReceiver, ReceiverDescriptor.NO_RECEIVER);
|
||||
propertyDescriptor.setType(
|
||||
parameter.getType(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
classDescriptor.getThisAsReceiverParameter(), ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER);
|
||||
//PropertyGetterDescriptor getter = DescriptorResolver.createDefaultGetter(propertyDescriptor);
|
||||
//getter.initialize(propertyDescriptor.getType());
|
||||
propertyDescriptor.initialize(null, null);
|
||||
|
||||
+1
-2
@@ -20,7 +20,6 @@ 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.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeSubstitutor;
|
||||
|
||||
@@ -52,7 +51,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
|
||||
|
||||
public SimpleFunctionDescriptorImpl initialize(
|
||||
@Nullable JetType receiverParameterType,
|
||||
@NotNull ReceiverDescriptor expectedThisObject,
|
||||
@NotNull ReceiverParameterDescriptor expectedThisObject,
|
||||
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> unsubstitutedValueParameters,
|
||||
@Nullable JetType unsubstitutedReturnType,
|
||||
|
||||
+4
-5
@@ -20,7 +20,6 @@ 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.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -89,14 +88,14 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getReceiverParameter() {
|
||||
return ReceiverDescriptor.NO_RECEIVER;
|
||||
public ReceiverParameterDescriptor getReceiverParameter() {
|
||||
return ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getExpectedThisObject() {
|
||||
return ReceiverDescriptor.NO_RECEIVER;
|
||||
public ReceiverParameterDescriptor getExpectedThisObject() {
|
||||
return ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.DEFERRED_TYPE;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
@@ -478,7 +479,7 @@ public class BodyResolver {
|
||||
|
||||
public void resolvePropertyInitializer(JetProperty property, PropertyDescriptor propertyDescriptor, JetExpression initializer, JetScope scope) {
|
||||
JetType expectedTypeForInitializer = property.getTypeRef() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
|
||||
JetScope propertyDeclarationInnerScope = descriptorResolver.getPropertyDeclarationInnerScope(scope, propertyDescriptor.getTypeParameters(), ReceiverDescriptor.NO_RECEIVER, trace);
|
||||
JetScope propertyDeclarationInnerScope = descriptorResolver.getPropertyDeclarationInnerScope(scope, propertyDescriptor.getTypeParameters(), NO_RECEIVER_PARAMETER, trace);
|
||||
expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer, DataFlowInfo.EMPTY, trace);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
@@ -45,6 +44,7 @@ import org.jetbrains.jet.util.lazy.LazyValueWithDefault;
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.CONSTRUCTOR;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getDefaultConstructorVisibility;
|
||||
@@ -336,7 +336,7 @@ public class DescriptorResolver {
|
||||
|
||||
functionDescriptor.initialize(
|
||||
null,
|
||||
classDescriptor.getImplicitReceiver(),
|
||||
classDescriptor.getThisAsReceiverParameter(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.<ValueParameterDescriptor>emptyList(),
|
||||
returnType,
|
||||
@@ -384,7 +384,7 @@ public class DescriptorResolver {
|
||||
|
||||
functionDescriptor.initialize(
|
||||
null,
|
||||
classDescriptor.getImplicitReceiver(),
|
||||
classDescriptor.getThisAsReceiverParameter(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
parameterDescriptors,
|
||||
returnType,
|
||||
@@ -735,7 +735,7 @@ public class DescriptorResolver {
|
||||
JetType type =
|
||||
getVariableType(scope, variable, dataFlowInfo, false, trace); // For a local variable the type must not be deferred
|
||||
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), scope.getImplicitReceiver(), (JetType) null);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(), NO_RECEIVER_PARAMETER, (JetType) null);
|
||||
trace.record(BindingContext.VARIABLE, variable, propertyDescriptor);
|
||||
return propertyDescriptor;
|
||||
}
|
||||
@@ -800,7 +800,7 @@ public class DescriptorResolver {
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
);
|
||||
propertyDescriptor.setType(classDescriptor.getDefaultType(), Collections.<TypeParameterDescriptor>emptyList(),
|
||||
getExpectedThisObjectIfNeeded(containingDeclaration), ReceiverDescriptor.NO_RECEIVER);
|
||||
getExpectedThisObjectIfNeeded(containingDeclaration), NO_RECEIVER_PARAMETER);
|
||||
propertyDescriptor.initialize(createDefaultGetter(propertyDescriptor), null);
|
||||
trace.record(BindingContext.OBJECT_DECLARATION_CLASS, propertyDescriptor, classDescriptor);
|
||||
JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration();
|
||||
@@ -899,9 +899,9 @@ public class DescriptorResolver {
|
||||
}
|
||||
}
|
||||
|
||||
ReceiverDescriptor receiverDescriptor = receiverType == null
|
||||
? ReceiverDescriptor.NO_RECEIVER
|
||||
: new ExtensionReceiver(propertyDescriptor, receiverType);
|
||||
ReceiverParameterDescriptor receiverDescriptor = receiverType == null
|
||||
? NO_RECEIVER_PARAMETER
|
||||
: new ReceiverParameterDescriptorImpl(propertyDescriptor, receiverType);
|
||||
|
||||
JetScope propertyScope = getPropertyDeclarationInnerScope(scope, typeParameterDescriptors, ReceiverDescriptor.NO_RECEIVER, trace);
|
||||
|
||||
@@ -1169,7 +1169,7 @@ public class DescriptorResolver {
|
||||
CallableMemberDescriptor.Kind.DECLARATION
|
||||
);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
getExpectedThisObjectIfNeeded(classDescriptor), ReceiverDescriptor.NO_RECEIVER);
|
||||
getExpectedThisObjectIfNeeded(classDescriptor), NO_RECEIVER_PARAMETER);
|
||||
|
||||
PropertyGetterDescriptor getter = createDefaultGetter(propertyDescriptor);
|
||||
PropertySetterDescriptor setter = propertyDescriptor.isVar() ? createDefaultSetter(propertyDescriptor) : null;
|
||||
@@ -1234,14 +1234,13 @@ public class DescriptorResolver {
|
||||
new SimpleFunctionDescriptorImpl(classObjectDescriptor, annotations,
|
||||
VALUES_METHOD_NAME,
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
ClassReceiver classReceiver = new ClassReceiver(classObjectDescriptor);
|
||||
JetType type = DeferredType.create(trace, new LazyValue<JetType>() {
|
||||
@Override
|
||||
protected JetType compute() {
|
||||
return KotlinBuiltIns.getInstance().getArrayType(enumClassDescriptor.getDefaultType());
|
||||
}
|
||||
});
|
||||
values.initialize(null, classReceiver, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
values.initialize(null, classObjectDescriptor.getThisAsReceiverParameter(), Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.<ValueParameterDescriptor>emptyList(),
|
||||
type, Modality.FINAL,
|
||||
Visibilities.PUBLIC, false);
|
||||
@@ -1259,7 +1258,6 @@ public class DescriptorResolver {
|
||||
new SimpleFunctionDescriptorImpl(classObjectDescriptor, annotations,
|
||||
VALUE_OF_METHOD_NAME,
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
ClassReceiver classReceiver = new ClassReceiver(classObjectDescriptor);
|
||||
JetType type = DeferredType.create(trace, new LazyValue<JetType>() {
|
||||
@Override
|
||||
protected JetType compute() {
|
||||
@@ -1275,7 +1273,7 @@ public class DescriptorResolver {
|
||||
KotlinBuiltIns.getInstance().getStringType(),
|
||||
false,
|
||||
null);
|
||||
values.initialize(null, classReceiver,
|
||||
values.initialize(null, classObjectDescriptor.getThisAsReceiverParameter(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
Collections.singletonList(parameterDescriptor),
|
||||
type, Modality.FINAL,
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -28,8 +27,6 @@ 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.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.DescriptorSubstitutor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
@@ -38,7 +35,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor.NO_RECEIVER;
|
||||
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -64,16 +61,16 @@ public class DescriptorUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ReceiverDescriptor getExpectedThisObjectIfNeeded(@NotNull DeclarationDescriptor containingDeclaration) {
|
||||
public static ReceiverParameterDescriptor getExpectedThisObjectIfNeeded(@NotNull DeclarationDescriptor containingDeclaration) {
|
||||
if (containingDeclaration instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
||||
return classDescriptor.getImplicitReceiver();
|
||||
return classDescriptor.getThisAsReceiverParameter();
|
||||
}
|
||||
else if (containingDeclaration instanceof ScriptDescriptor) {
|
||||
ScriptDescriptor scriptDescriptor = (ScriptDescriptor) containingDeclaration;
|
||||
return scriptDescriptor.getImplicitReceiver();
|
||||
return scriptDescriptor.getThisAsReceiverParameter();
|
||||
}
|
||||
return NO_RECEIVER;
|
||||
return NO_RECEIVER_PARAMETER;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.google.common.collect.Sets;
|
||||
import com.intellij.util.Function;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
|
||||
@@ -112,7 +111,7 @@ public class OverridingUtil {
|
||||
}
|
||||
|
||||
private static List<JetType> compiledValueParameters(CallableDescriptor callableDescriptor) {
|
||||
ReceiverDescriptor receiverParameter = callableDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = callableDescriptor.getReceiverParameter();
|
||||
ArrayList<JetType> parameters = new ArrayList<JetType>();
|
||||
if (receiverParameter.exists()) {
|
||||
parameters.add(receiverParameter.getType());
|
||||
|
||||
@@ -145,7 +145,7 @@ public class ScriptHeaderResolver {
|
||||
|
||||
List<ValueParameterDescriptor> valueParameters = Lists.newArrayList();
|
||||
|
||||
scope.setImplicitReceiver(descriptor.getImplicitReceiver());
|
||||
scope.setImplicitReceiver(descriptor.getThisAsReceiverParameter());
|
||||
|
||||
JetFile file = (JetFile) declaration.getContainingFile();
|
||||
JetScriptDefinition scriptDefinition = JetScriptDefinitionProvider.getInstance(file.getProject()).findScriptDefinition(file);
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.results.ResolutionStatus.*;
|
||||
@@ -240,7 +241,7 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
FunctionDescriptorImpl functionDescriptor = new ExpressionAsFunctionDescriptor(context.scope.getContainingDeclaration(), Name.special("<for expression " + calleeExpression.getText() + ">"));
|
||||
FunctionDescriptorUtil.initializeFromFunctionType(functionDescriptor, calleeType, NO_RECEIVER, Modality.FINAL, Visibilities.LOCAL);
|
||||
FunctionDescriptorUtil.initializeFromFunctionType(functionDescriptor, calleeType, NO_RECEIVER_PARAMETER, Modality.FINAL, Visibilities.LOCAL);
|
||||
ResolutionCandidate<CallableDescriptor> resolutionCandidate = ResolutionCandidate.<CallableDescriptor>create(functionDescriptor, JetPsiUtil.isSafeCall(context.call));
|
||||
resolutionCandidate.setReceiverArgument(context.call.getExplicitReceiver());
|
||||
resolutionCandidate.setExplicitReceiverKind(ExplicitReceiverKind.RECEIVER_ARGUMENT);
|
||||
@@ -591,7 +592,7 @@ public class CallResolver {
|
||||
boolean found = false;
|
||||
for (ResolutionCandidate<FunctionDescriptor> candidate : candidates) {
|
||||
FunctionDescriptor functionDescriptor = candidate.getDescriptor();
|
||||
ReceiverDescriptor functionReceiver = functionDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor functionReceiver = functionDescriptor.getReceiverParameter();
|
||||
if (!functionReceiver.exists()) continue;
|
||||
if (!functionDescriptor.getTypeParameters().isEmpty()) continue;
|
||||
if (!typeChecker.isSubtypeOf(receiver.getType(), functionReceiver.getType())) continue;
|
||||
|
||||
@@ -315,7 +315,7 @@ public class CandidateResolver {
|
||||
// Receiver
|
||||
// Error is already reported if something is missing
|
||||
ReceiverDescriptor receiverArgument = candidateCall.getReceiverArgument();
|
||||
ReceiverDescriptor receiverParameter = candidateWithFreshVariables.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = candidateWithFreshVariables.getReceiverParameter();
|
||||
if (receiverArgument.exists() && receiverParameter.exists()) {
|
||||
constraintsSystem.addSubtypeConstraint(receiverParameter.getType(), receiverArgument.getType(),
|
||||
ConstraintPosition.RECEIVER_POSITION);
|
||||
@@ -467,7 +467,7 @@ public class CandidateResolver {
|
||||
}
|
||||
|
||||
private <D extends CallableDescriptor, F extends D> ResolutionStatus checkReceiver(CallResolutionContext<D, F> context, ResolvedCall<D> candidateCall,
|
||||
ReceiverDescriptor receiverParameter, ReceiverDescriptor receiverArgument,
|
||||
ReceiverParameterDescriptor receiverParameter, ReceiverDescriptor receiverArgument,
|
||||
boolean isExplicitReceiver, boolean implicitInvokeCheck) {
|
||||
|
||||
BindingContext bindingContext = context.candidateCall.getTrace().getBindingContext();
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import com.google.common.collect.Sets;
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
||||
@@ -211,7 +212,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
|
||||
}
|
||||
}
|
||||
|
||||
ReceiverDescriptor receiverParameter = candidate.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = candidate.getReceiverParameter();
|
||||
ReceiverDescriptor receiverArgument = candidateCall.getReceiverArgument();
|
||||
if (receiverParameter.exists() &&!receiverArgument.exists()) {
|
||||
tracing.missingReceiver(traceForCall, receiverParameter);
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ public class DataFlowValueFactory {
|
||||
return Pair.create((Object) ((CallableDescriptor) declarationDescriptor).getReceiverParameter(), true);
|
||||
}
|
||||
if (declarationDescriptor instanceof ClassDescriptor) {
|
||||
return Pair.create((Object) ((ClassDescriptor) declarationDescriptor).getImplicitReceiver(), true);
|
||||
return Pair.create((Object) ((ClassDescriptor) declarationDescriptor).getThisAsReceiverParameter(), true);
|
||||
}
|
||||
return Pair.create(null, true);
|
||||
}
|
||||
|
||||
+3
-3
@@ -21,12 +21,12 @@ import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
@@ -93,8 +93,8 @@ public class OverloadingConflictResolver {
|
||||
if (OverridingUtil.overrides(f, g)) return true;
|
||||
if (OverridingUtil.overrides(g, f)) return false;
|
||||
|
||||
ReceiverDescriptor receiverOfF = f.getReceiverParameter();
|
||||
ReceiverDescriptor receiverOfG = g.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverOfF = f.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverOfG = g.getReceiverParameter();
|
||||
if (f.getReceiverParameter().exists() && g.getReceiverParameter().exists()) {
|
||||
if (!typeMoreSpecific(receiverOfF.getType(), receiverOfG.getType())) return false;
|
||||
}
|
||||
|
||||
+2
-2
@@ -149,12 +149,12 @@ public class ResolutionTask<D extends CallableDescriptor, F extends D> extends R
|
||||
}
|
||||
|
||||
@Override
|
||||
public void missingReceiver(@NotNull BindingTrace trace, @NotNull ReceiverDescriptor expectedReceiver) {
|
||||
public void missingReceiver(@NotNull BindingTrace trace, @NotNull ReceiverParameterDescriptor expectedReceiver) {
|
||||
trace.report(MISSING_RECEIVER.on(reference, expectedReceiver.getType()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wrongReceiverType(@NotNull BindingTrace trace, @NotNull ReceiverDescriptor receiverParameter, @NotNull ReceiverDescriptor receiverArgument) {
|
||||
public void wrongReceiverType(@NotNull BindingTrace trace, @NotNull ReceiverParameterDescriptor receiverParameter, @NotNull ReceiverDescriptor receiverArgument) {
|
||||
if (receiverArgument instanceof ExpressionReceiver) {
|
||||
ExpressionReceiver expressionReceiver = (ExpressionReceiver)receiverArgument;
|
||||
trace.report(TYPE_MISMATCH.on(expressionReceiver.getExpression(), receiverParameter.getType(), receiverArgument.getType()));
|
||||
|
||||
+1
-1
@@ -224,7 +224,7 @@ public abstract class TaskPrioritizer {
|
||||
}
|
||||
|
||||
private static <D extends CallableDescriptor> boolean setImpliedThis(@NotNull JetScope scope, ResolutionCandidate<D> candidate) {
|
||||
ReceiverDescriptor expectedThisObject = candidate.getDescriptor().getExpectedThisObject();
|
||||
ReceiverParameterDescriptor expectedThisObject = candidate.getDescriptor().getExpectedThisObject();
|
||||
if (!expectedThisObject.exists()) return true;
|
||||
List<ReceiverDescriptor> receivers = Lists.newArrayList();
|
||||
scope.getImplicitReceiversHierarchy(receivers);
|
||||
|
||||
+5
-4
@@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.resolve.calls.tasks;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorWithVisibility;
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
@@ -52,10 +53,10 @@ public interface TracingStrategy {
|
||||
public <D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCallWithTrace<D>> candidates) {}
|
||||
|
||||
@Override
|
||||
public void missingReceiver(@NotNull BindingTrace trace, @NotNull ReceiverDescriptor expectedReceiver) {}
|
||||
public void missingReceiver(@NotNull BindingTrace trace, @NotNull ReceiverParameterDescriptor expectedReceiver) {}
|
||||
|
||||
@Override
|
||||
public void wrongReceiverType(@NotNull BindingTrace trace, @NotNull ReceiverDescriptor receiverParameter, @NotNull ReceiverDescriptor receiverArgument) {}
|
||||
public void wrongReceiverType(@NotNull BindingTrace trace, @NotNull ReceiverParameterDescriptor receiverParameter, @NotNull ReceiverDescriptor receiverArgument) {}
|
||||
|
||||
@Override
|
||||
public void noReceiverAllowed(@NotNull BindingTrace trace) {}
|
||||
@@ -103,9 +104,9 @@ public interface TracingStrategy {
|
||||
|
||||
<D extends CallableDescriptor> void recordAmbiguity(BindingTrace trace, Collection<ResolvedCallWithTrace<D>> candidates);
|
||||
|
||||
void missingReceiver(@NotNull BindingTrace trace, @NotNull ReceiverDescriptor expectedReceiver);
|
||||
void missingReceiver(@NotNull BindingTrace trace, @NotNull ReceiverParameterDescriptor expectedReceiver);
|
||||
|
||||
void wrongReceiverType(@NotNull BindingTrace trace, @NotNull ReceiverDescriptor receiverParameter, @NotNull ReceiverDescriptor receiverArgument);
|
||||
void wrongReceiverType(@NotNull BindingTrace trace, @NotNull ReceiverParameterDescriptor receiverParameter, @NotNull ReceiverDescriptor receiverArgument);
|
||||
|
||||
void noReceiverAllowed(@NotNull BindingTrace trace);
|
||||
|
||||
|
||||
@@ -35,8 +35,6 @@ import org.jetbrains.jet.lang.resolve.lazy.data.JetClassInfoUtil;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.data.JetClassLikeInfo;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeConstructor;
|
||||
@@ -70,7 +68,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
||||
private final Visibility visibility;
|
||||
private final ClassKind kind;
|
||||
|
||||
private ClassReceiver implicitReceiver;
|
||||
private ReceiverParameterDescriptor thisAsReceiverParameter;
|
||||
private List<AnnotationDescriptor> annotations;
|
||||
private ClassDescriptor classObjectDescriptor;
|
||||
private boolean classObjectDescriptorResolved = false;
|
||||
@@ -273,11 +271,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getImplicitReceiver() {
|
||||
if (implicitReceiver == null) {
|
||||
implicitReceiver = new ClassReceiver(this);
|
||||
public ReceiverParameterDescriptor getThisAsReceiverParameter() {
|
||||
if (thisAsReceiverParameter == null) {
|
||||
thisAsReceiverParameter = new ReceiverParameterDescriptorImpl(this, getDefaultType());
|
||||
}
|
||||
return implicitReceiver;
|
||||
return thisAsReceiverParameter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -315,7 +313,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
||||
getClassObjectType();
|
||||
getConstructors();
|
||||
getContainingDeclaration();
|
||||
getImplicitReceiver();
|
||||
getThisAsReceiverParameter();
|
||||
getKind();
|
||||
getModality();
|
||||
getName();
|
||||
|
||||
@@ -324,7 +324,7 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
|
||||
@NotNull
|
||||
@Override
|
||||
public ReceiverDescriptor getImplicitReceiver() {
|
||||
return thisDescriptor.getImplicitReceiver();
|
||||
return thisDescriptor.getThisAsReceiverParameter();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -372,9 +372,9 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
|
||||
private void checkForPropertyRedeclaration(@NotNull Name name, VariableDescriptor variableDescriptor) {
|
||||
Set<VariableDescriptor> properties = getPropertyGroups().get(name);
|
||||
ReceiverDescriptor receiverParameter = variableDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = variableDescriptor.getReceiverParameter();
|
||||
for (VariableDescriptor oldProperty : properties) {
|
||||
ReceiverDescriptor receiverParameterForOldVariable = oldProperty.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameterForOldVariable = oldProperty.getReceiverParameter();
|
||||
if (((receiverParameter.exists() && receiverParameterForOldVariable.exists()) &&
|
||||
(JetTypeChecker.INSTANCE.equalTypes(receiverParameter.getType(), receiverParameterForOldVariable.getType())))) {
|
||||
redeclarationHandler.handleRedeclaration(oldProperty, variableDescriptor);
|
||||
|
||||
@@ -163,7 +163,7 @@ public class ErrorUtils {
|
||||
Visibilities.INTERNAL,
|
||||
true,
|
||||
null,
|
||||
ReceiverDescriptor.NO_RECEIVER,
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER,
|
||||
Name.special("<ERROR PROPERTY>"),
|
||||
ERROR_PROPERTY_TYPE,
|
||||
CallableMemberDescriptor.Kind.DECLARATION);
|
||||
@@ -173,7 +173,7 @@ public class ErrorUtils {
|
||||
ErrorSimpleFunctionDescriptorImpl function = new ErrorSimpleFunctionDescriptorImpl(ownerScope);
|
||||
function.initialize(
|
||||
null,
|
||||
ReceiverDescriptor.NO_RECEIVER,
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER,
|
||||
Collections.<TypeParameterDescriptorImpl>emptyList(), // TODO
|
||||
Collections.<ValueParameterDescriptor>emptyList(), // TODO
|
||||
createErrorType("<ERROR FUNCTION RETURN TYPE>"),
|
||||
|
||||
+2
-2
@@ -504,8 +504,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
|
||||
@Nullable // No class receivers
|
||||
private ReceiverDescriptor resolveToReceiver(JetLabelQualifiedInstanceExpression expression, ExpressionTypingContext context, boolean onlyClassReceivers) {
|
||||
ReceiverDescriptor thisReceiver = null;
|
||||
private ReceiverParameterDescriptor resolveToReceiver(JetLabelQualifiedInstanceExpression expression, ExpressionTypingContext context, boolean onlyClassReceivers) {
|
||||
ReceiverParameterDescriptor thisReceiver = null;
|
||||
String labelName = expression.getLabelName();
|
||||
if (labelName != null) {
|
||||
thisReceiver = context.labelResolver.resolveThisLabel(
|
||||
|
||||
+3
-7
@@ -16,18 +16,15 @@
|
||||
|
||||
package org.jetbrains.jet.lang.types.expressions;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.util.lazy.LazyValueWithDefault;
|
||||
@@ -38,7 +35,6 @@ import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.CANNOT_INFER_PARAMETER_TYPE;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor.NO_RECEIVER;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -107,8 +103,8 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
for (ValueParameterDescriptor valueParameter : valueParameters) {
|
||||
parameterTypes.add(valueParameter.getType());
|
||||
}
|
||||
ReceiverDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
||||
JetType receiver = receiverParameter != NO_RECEIVER ? receiverParameter.getType() : null;
|
||||
ReceiverParameterDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
||||
JetType receiver = receiverParameter.exists() ? receiverParameter.getType() : null;
|
||||
|
||||
JetType returnType = TypeUtils.NO_EXPECTED_TYPE;
|
||||
JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(context.scope, functionDescriptor, context.trace);
|
||||
@@ -168,7 +164,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
effectiveReceiverType = context.expressionTypingServices.getTypeResolver().resolveType(context.scope, receiverTypeRef, context.trace, true);
|
||||
}
|
||||
functionDescriptor.initialize(effectiveReceiverType,
|
||||
NO_RECEIVER,
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER,
|
||||
Collections.<TypeParameterDescriptorImpl>emptyList(),
|
||||
valueParameterDescriptors,
|
||||
/*unsubstitutedReturnType = */ null,
|
||||
|
||||
+11
-11
@@ -209,41 +209,41 @@ public class ExpressionTypingUtils {
|
||||
* Checks if receiver declaration could be resolved to call expected receiver.
|
||||
*/
|
||||
public static boolean checkIsExtensionCallable (
|
||||
@NotNull ReceiverDescriptor expectedReceiver,
|
||||
@NotNull CallableDescriptor receiverArgument
|
||||
@NotNull ReceiverDescriptor receiverArgument,
|
||||
@NotNull CallableDescriptor callableDescriptor
|
||||
) {
|
||||
JetType type = expectedReceiver.getType();
|
||||
JetType type = receiverArgument.getType();
|
||||
|
||||
if (type instanceof NamespaceType) {
|
||||
// This fake class ruins standard algorithms
|
||||
return false;
|
||||
}
|
||||
|
||||
if (checkReceiverResolution(expectedReceiver, type, receiverArgument)) return true;
|
||||
if (checkReceiverResolution(receiverArgument, type, callableDescriptor)) return true;
|
||||
if (type.isNullable()) {
|
||||
JetType notNullableType = TypeUtils.makeNotNullable(type);
|
||||
if (checkReceiverResolution(expectedReceiver, notNullableType, receiverArgument)) return true;
|
||||
if (checkReceiverResolution(receiverArgument, notNullableType, callableDescriptor)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkReceiverResolution (
|
||||
@NotNull ReceiverDescriptor expectedReceiver,
|
||||
@NotNull ReceiverDescriptor receiverArgument,
|
||||
@NotNull JetType receiverType,
|
||||
@NotNull CallableDescriptor callableDescriptor
|
||||
) {
|
||||
ReceiverDescriptor callReceiver = callableDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = callableDescriptor.getReceiverParameter();
|
||||
|
||||
if (!expectedReceiver.exists() && !callReceiver.exists()) {
|
||||
if (!receiverArgument.exists() && !receiverParameter.exists()) {
|
||||
// Both receivers do not exist
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(expectedReceiver.exists() && callReceiver.exists())) {
|
||||
if (!(receiverArgument.exists() && receiverParameter.exists())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<Name> typeNamesInReceiver = collectUsedTypeNames(callReceiver.getType());
|
||||
Set<Name> typeNamesInReceiver = collectUsedTypeNames(receiverParameter.getType());
|
||||
|
||||
ConstraintSystem constraintSystem = new ConstraintSystemImpl();
|
||||
for (TypeParameterDescriptor typeParameterDescriptor : callableDescriptor.getTypeParameters()) {
|
||||
@@ -252,7 +252,7 @@ public class ExpressionTypingUtils {
|
||||
}
|
||||
}
|
||||
|
||||
constraintSystem.addSubtypeConstraint(callReceiver.getType(), receiverType, ConstraintPosition.RECEIVER_POSITION);
|
||||
constraintSystem.addSubtypeConstraint(receiverParameter.getType(), receiverType, ConstraintPosition.RECEIVER_POSITION);
|
||||
return constraintSystem.isSuccessful() && ConstraintsUtil.checkBoundsAreSatisfied(constraintSystem);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.LabelName;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -124,8 +124,8 @@ public class LabelResolver {
|
||||
return result;
|
||||
}
|
||||
|
||||
public ReceiverDescriptor resolveThisLabel(JetReferenceExpression thisReference, JetSimpleNameExpression targetLabel,
|
||||
ExpressionTypingContext context, ReceiverDescriptor thisReceiver, LabelName labelName) {
|
||||
public ReceiverParameterDescriptor resolveThisLabel(JetReferenceExpression thisReference, JetSimpleNameExpression targetLabel,
|
||||
ExpressionTypingContext context, ReceiverParameterDescriptor thisReceiver, LabelName labelName) {
|
||||
Collection<DeclarationDescriptor> declarationsByLabel = context.scope.getDeclarationsByLabel(labelName);
|
||||
int size = declarationsByLabel.size();
|
||||
assert targetLabel != null;
|
||||
@@ -133,7 +133,7 @@ public class LabelResolver {
|
||||
DeclarationDescriptor declarationDescriptor = declarationsByLabel.iterator().next();
|
||||
if (declarationDescriptor instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor;
|
||||
thisReceiver = classDescriptor.getImplicitReceiver();
|
||||
thisReceiver = classDescriptor.getThisAsReceiverParameter();
|
||||
}
|
||||
else if (declarationDescriptor instanceof FunctionDescriptor) {
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) declarationDescriptor;
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.jet.lang.diagnostics.rendering.Renderer;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
@@ -344,7 +343,7 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
builder,
|
||||
skipValVar ? null : descriptor.isVar(),
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
ReceiverDescriptor.NO_RECEIVER,
|
||||
ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER,
|
||||
type);
|
||||
renderName(descriptor, builder);
|
||||
builder.append(" : ").append(escape(typeString));
|
||||
@@ -355,7 +354,7 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
@NotNull StringBuilder builder,
|
||||
@Nullable Boolean isVar,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull ReceiverDescriptor receiver,
|
||||
@NotNull ReceiverParameterDescriptor receiver,
|
||||
@Nullable JetType outType) {
|
||||
String typeString = lt() + "no type>";
|
||||
if (outType != null) {
|
||||
@@ -424,7 +423,7 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
builder.append(" ");
|
||||
}
|
||||
|
||||
ReceiverDescriptor receiver = descriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiver = descriptor.getReceiverParameter();
|
||||
if (receiver.exists()) {
|
||||
builder.append(escape(renderType(receiver.getType()))).append(".");
|
||||
}
|
||||
@@ -446,6 +445,11 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
return visitFunctionDescriptor(descriptor, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitReceiverParameterDescriptor(ReceiverParameterDescriptor descriptor, StringBuilder data) {
|
||||
throw new UnsupportedOperationException("Don't render receiver parameters");
|
||||
}
|
||||
|
||||
private void renderWhereSuffix(@NotNull CallableMemberDescriptor callable, @NotNull StringBuilder builder) {
|
||||
boolean first = true;
|
||||
for (TypeParameterDescriptor typeParameter : callable.getTypeParameters()) {
|
||||
|
||||
@@ -437,8 +437,8 @@ public class NamespaceComparator {
|
||||
}
|
||||
}
|
||||
|
||||
public void serialize(ExtensionReceiver extensionReceiver) {
|
||||
serialize(extensionReceiver.getType());
|
||||
public void serialize(ReceiverParameterDescriptor receiverParameterDescriptor) {
|
||||
serialize(receiverParameterDescriptor.getType());
|
||||
}
|
||||
|
||||
private void serialize(@NotNull PropertyAccessorDescriptor accessor) {
|
||||
|
||||
@@ -33,13 +33,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -241,7 +243,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
|
||||
}
|
||||
|
||||
private static void addReceiverParameter(CallableDescriptor descriptor, StringBuilder bodyBuilder) {
|
||||
ReceiverDescriptor receiverParameter = descriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
|
||||
if (receiverParameter.exists()) {
|
||||
bodyBuilder.append(receiverParameter.getType()).append(".");
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@ package org.jetbrains.jet.plugin.highlighter;
|
||||
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
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.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
|
||||
/**
|
||||
* @author Evgeny Gerashchenko
|
||||
@@ -73,7 +75,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
|
||||
if (fun.getContainingDeclaration() instanceof NamespaceDescriptor) {
|
||||
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.NAMESPACE_FUNCTION_CALL);
|
||||
}
|
||||
if (fun.getReceiverParameter() != ReceiverDescriptor.NO_RECEIVER) {
|
||||
if (fun.getReceiverParameter().exists()) {
|
||||
JetPsiChecker.highlightName(holder, callee, JetHighlightingColors.EXTENSION_FUNCTION_CALL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +30,12 @@ import org.jetbrains.jet.lang.diagnostics.rendering.Renderer;
|
||||
import org.jetbrains.jet.lang.psi.JetValueArgument;
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
@@ -141,7 +140,7 @@ public class IdeRenderers {
|
||||
Set<ValueParameterDescriptor> parametersToHighlight = getParametersToHighlight(call);
|
||||
|
||||
DescriptorRenderer htmlRenderer = DescriptorRenderer.HTML;
|
||||
if (funDescriptor.getReceiverParameter() != ReceiverDescriptor.NO_RECEIVER) {
|
||||
if (funDescriptor.getReceiverParameter().exists()) {
|
||||
stringBuilder.append(htmlRenderer.renderType(funDescriptor.getReceiverParameter().getType())).append(".");
|
||||
}
|
||||
stringBuilder.append(funDescriptor.getName()).append("(");
|
||||
|
||||
@@ -19,10 +19,15 @@ 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.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
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.psi.JetParameter;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetThisExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
@@ -79,7 +84,7 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
JetPsiChecker.highlightName(holder, elementToHighlight,
|
||||
namespace ? JetHighlightingColors.NAMESPACE_PROPERTY : JetHighlightingColors.INSTANCE_PROPERTY
|
||||
);
|
||||
if (descriptor.getReceiverParameter() != ReceiverDescriptor.NO_RECEIVER) {
|
||||
if (descriptor.getReceiverParameter().exists()) {
|
||||
JetPsiChecker.highlightName(holder, elementToHighlight, JetHighlightingColors.EXTENSION_PROPERTY);
|
||||
}
|
||||
if (withBackingField) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.jet.plugin.libraries;
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
import java.util.Comparator;
|
||||
@@ -36,7 +35,7 @@ class DeclarationDescriptorComparator implements Comparator<DeclarationDescripto
|
||||
}
|
||||
else if (descriptor instanceof FunctionDescriptor) {
|
||||
FunctionDescriptor fun = (FunctionDescriptor)descriptor;
|
||||
if (fun.getReceiverParameter() == ReceiverDescriptor.NO_RECEIVER) {
|
||||
if (!fun.getReceiverParameter().exists()) {
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
@@ -65,7 +64,7 @@ class DeclarationDescriptorComparator implements Comparator<DeclarationDescripto
|
||||
CallableDescriptor c1 = (CallableDescriptor)o1;
|
||||
CallableDescriptor c2 = (CallableDescriptor)o2;
|
||||
|
||||
if (c1.getReceiverParameter() != ReceiverDescriptor.NO_RECEIVER && c2.getReceiverParameter() != ReceiverDescriptor.NO_RECEIVER) {
|
||||
if (c1.getReceiverParameter().exists() && c2.getReceiverParameter().exists()) {
|
||||
String r1 = DescriptorRenderer.TEXT.renderType(c1.getReceiverParameter().getType());
|
||||
String r2 = DescriptorRenderer.TEXT.renderType(c2.getReceiverParameter().getType());
|
||||
int receiversCompareTo = r1.compareTo(r2);
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
@@ -165,7 +164,7 @@ public class JetSourceNavigationHelper {
|
||||
if (receiverType == null) {
|
||||
// non-extension property
|
||||
for (Descr candidate : matcher.getCandidatesFromScope(namespaceDescriptor.getMemberScope(), entityNameAsName)) {
|
||||
if (candidate.getReceiverParameter() == ReceiverDescriptor.NO_RECEIVER) {
|
||||
if (!candidate.getReceiverParameter().exists()) {
|
||||
if (matcher.areSame(decompiledDeclaration, candidate)) {
|
||||
return (JetDeclaration) BindingContextUtils.descriptorToDeclaration(bindingContext, candidate);
|
||||
}
|
||||
@@ -176,7 +175,7 @@ public class JetSourceNavigationHelper {
|
||||
// extension property
|
||||
String expectedTypeString = receiverType.getText();
|
||||
for (Descr candidate : matcher.getCandidatesFromScope(namespaceDescriptor.getMemberScope(), entityNameAsName)) {
|
||||
if (candidate.getReceiverParameter() != ReceiverDescriptor.NO_RECEIVER) {
|
||||
if (candidate.getReceiverParameter().exists()) {
|
||||
String thisReceiverType = DescriptorRenderer.TEXT.renderType(candidate.getReceiverParameter().getType());
|
||||
if (expectedTypeString.equals(thisReceiverType)) {
|
||||
if (matcher.areSame(decompiledDeclaration, candidate)) {
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.project.WholeProjectAnalyzerFacade;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
@@ -195,7 +194,7 @@ public class JetStructureViewElement implements StructureViewTreeElement {
|
||||
textBuilder = new StringBuilder();
|
||||
|
||||
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
|
||||
ReceiverDescriptor receiver = functionDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiver = functionDescriptor.getReceiverParameter();
|
||||
if (receiver.exists()) {
|
||||
textBuilder.append(DescriptorRenderer.TEXT.renderType(receiver.getType())).append(".");
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ public final class CallBuilder {
|
||||
private CallTranslator finish() {
|
||||
if (resolvedCall == null) {
|
||||
assert descriptor != null;
|
||||
resolvedCall = ResolvedCallImpl.create(ResolutionCandidate.create(descriptor, descriptor.getExpectedThisObject(),
|
||||
descriptor.getReceiverParameter(),
|
||||
resolvedCall = ResolvedCallImpl.create(ResolutionCandidate.create(descriptor, descriptor.getExpectedThisObject().getValue(),
|
||||
descriptor.getReceiverParameter().getValue(),
|
||||
ExplicitReceiverKind.THIS_OBJECT, false),
|
||||
TemporaryBindingTrace.create(new BindingTraceContext(), "trace to resolve call (in js)"));
|
||||
}
|
||||
|
||||
@@ -91,11 +91,11 @@ public final class JsDescriptorUtils {
|
||||
//TODO: why callable descriptor
|
||||
@Nullable
|
||||
public static DeclarationDescriptor getExpectedThisDescriptor(@NotNull CallableDescriptor callableDescriptor) {
|
||||
ReceiverDescriptor expectedThisObject = callableDescriptor.getExpectedThisObject();
|
||||
ReceiverParameterDescriptor expectedThisObject = callableDescriptor.getExpectedThisObject();
|
||||
if (!expectedThisObject.exists()) {
|
||||
return null;
|
||||
}
|
||||
return getDeclarationDescriptorForReceiver(expectedThisObject);
|
||||
return getDeclarationDescriptorForReceiver(expectedThisObject.getValue());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -110,11 +110,11 @@ public final class JsDescriptorUtils {
|
||||
|
||||
@Nullable
|
||||
public static DeclarationDescriptor getExpectedReceiverDescriptor(@NotNull CallableDescriptor callableDescriptor) {
|
||||
ReceiverDescriptor receiverParameter = callableDescriptor.getReceiverParameter();
|
||||
ReceiverParameterDescriptor receiverParameter = callableDescriptor.getReceiverParameter();
|
||||
if (!receiverParameter.exists()) {
|
||||
return null;
|
||||
}
|
||||
return getDeclarationDescriptorForReceiver(receiverParameter);
|
||||
return getDeclarationDescriptorForReceiver(receiverParameter.getValue());
|
||||
}
|
||||
|
||||
//TODO: maybe we have similar routine
|
||||
|
||||
Reference in New Issue
Block a user