Minor, don't store type in receiver parameter
This commit is contained in:
@@ -16,46 +16,28 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.calls.tasks
|
package org.jetbrains.kotlin.resolve.calls.tasks
|
||||||
|
|
||||||
import org.jetbrains.kotlin.psi.Call
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.*
|
||||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.types.DynamicType
|
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.types.Variance
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.types.JetType
|
|
||||||
import kotlin.platform.platformStatic
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
|
||||||
import org.jetbrains.kotlin.types.isDynamic
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollector
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollectors
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens
|
import org.jetbrains.kotlin.lexer.JetTokens
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.JetOperationReferenceExpression
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollector
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollectors
|
||||||
import org.jetbrains.kotlin.psi.ValueArgument
|
|
||||||
import java.util.ArrayList
|
|
||||||
import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression
|
|
||||||
import org.jetbrains.kotlin.psi.JetPsiUtil
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||||
|
import org.jetbrains.kotlin.types.DynamicType
|
||||||
|
import org.jetbrains.kotlin.types.JetType
|
||||||
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
|
import org.jetbrains.kotlin.types.isDynamic
|
||||||
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
|
import java.util.ArrayList
|
||||||
|
import kotlin.platform.platformStatic
|
||||||
|
|
||||||
object DynamicCallableDescriptors {
|
object DynamicCallableDescriptors {
|
||||||
|
|
||||||
@@ -150,11 +132,7 @@ object DynamicCallableDescriptors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createDynamicDispatchReceiverParameter(owner: CallableDescriptor): ReceiverParameterDescriptorImpl {
|
private fun createDynamicDispatchReceiverParameter(owner: CallableDescriptor): ReceiverParameterDescriptorImpl {
|
||||||
return ReceiverParameterDescriptorImpl(
|
return ReceiverParameterDescriptorImpl(owner, TransientReceiver(DynamicType))
|
||||||
owner,
|
|
||||||
DynamicType,
|
|
||||||
TransientReceiver(DynamicType)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTypeParameters(owner: DeclarationDescriptor, call: Call): List<TypeParameterDescriptor> = call.getTypeArguments().indices.map {
|
private fun createTypeParameters(owner: DeclarationDescriptor, call: Call): List<TypeParameterDescriptor> = call.getTypeArguments().indices.map {
|
||||||
|
|||||||
+2
-3
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||||
|
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorVisitor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorVisitor
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
||||||
@@ -56,7 +55,7 @@ public class LazyScriptDescriptor(
|
|||||||
resolveSession.getTrace().record(BindingContext.SCRIPT, jetScript, this)
|
resolveSession.getTrace().record(BindingContext.SCRIPT, jetScript, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val implicitReceiver = ReceiverParameterDescriptorImpl(this, KotlinBuiltIns.getInstance().getAnyType(), ScriptReceiver(this))
|
private val implicitReceiver = ReceiverParameterDescriptorImpl(this, ScriptReceiver(this))
|
||||||
|
|
||||||
override fun getThisAsReceiverParameter() = implicitReceiver
|
override fun getThisAsReceiverParameter() = implicitReceiver
|
||||||
|
|
||||||
@@ -81,7 +80,7 @@ public class LazyScriptDescriptor(
|
|||||||
override fun getScriptCodeDescriptor() = scriptCodeDescriptor()
|
override fun getScriptCodeDescriptor() = scriptCodeDescriptor()
|
||||||
|
|
||||||
override fun getScopeForBodyResolution(): JetScope {
|
override fun getScopeForBodyResolution(): JetScope {
|
||||||
val parametersScope = WritableScopeImpl(JetScope.Empty, this, RedeclarationHandler.DO_NOTHING, "Parameters of " + this, implicitReceiver)
|
val parametersScope = WritableScopeImpl(JetScope.Empty, this, RedeclarationHandler.DO_NOTHING, "Parameters of $this", implicitReceiver)
|
||||||
for (valueParameterDescriptor in getScriptCodeDescriptor().getValueParameters()) {
|
for (valueParameterDescriptor in getScriptCodeDescriptor().getValueParameters()) {
|
||||||
parametersScope.addVariableDescriptor(valueParameterDescriptor)
|
parametersScope.addVariableDescriptor(valueParameterDescriptor)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -571,7 +571,6 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
|||||||
public List<ReceiverParameterDescriptor> getImplicitReceiversHierarchy() {
|
public List<ReceiverParameterDescriptor> getImplicitReceiversHierarchy() {
|
||||||
return Lists.<ReceiverParameterDescriptor>newArrayList(new ReceiverParameterDescriptorImpl(
|
return Lists.<ReceiverParameterDescriptor>newArrayList(new ReceiverParameterDescriptorImpl(
|
||||||
getContainingDeclaration(),
|
getContainingDeclaration(),
|
||||||
thisType,
|
|
||||||
new ExpressionReceiver(JetPsiFactory(getProject()).createExpression(expression), thisType)
|
new ExpressionReceiver(JetPsiFactory(getProject()).createExpression(expression), thisType)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -44,7 +44,7 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes
|
|||||||
JetType substitutedType = substitutor.substitute(getType(), Variance.INVARIANT);
|
JetType substitutedType = substitutor.substitute(getType(), Variance.INVARIANT);
|
||||||
if (substitutedType == null) return null;
|
if (substitutedType == null) return null;
|
||||||
|
|
||||||
return new ReceiverParameterDescriptorImpl(getContainingDeclaration(), substitutedType, new TransientReceiver(substitutedType));
|
return new ReceiverParameterDescriptorImpl(getContainingDeclaration(), new TransientReceiver(substitutedType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,6 +76,12 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes
|
|||||||
return getType();
|
return getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public JetType getType() {
|
||||||
|
return getValue().getType();
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<ValueParameterDescriptor> getValueParameters() {
|
public List<ValueParameterDescriptor> getValueParameters() {
|
||||||
|
|||||||
-7
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
|||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ClassReceiver;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ClassReceiver;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
|
||||||
|
|
||||||
public class LazyClassReceiverParameterDescriptor extends AbstractReceiverParameterDescriptor {
|
public class LazyClassReceiverParameterDescriptor extends AbstractReceiverParameterDescriptor {
|
||||||
private final ClassDescriptor descriptor;
|
private final ClassDescriptor descriptor;
|
||||||
@@ -32,12 +31,6 @@ public class LazyClassReceiverParameterDescriptor extends AbstractReceiverParame
|
|||||||
this.receiverValue = new ClassReceiver(descriptor);
|
this.receiverValue = new ClassReceiver(descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public JetType getType() {
|
|
||||||
return descriptor.getDefaultType();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ReceiverValue getValue() {
|
public ReceiverValue getValue() {
|
||||||
|
|||||||
+1
-14
@@ -19,29 +19,16 @@ package org.jetbrains.kotlin.descriptors.impl;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
|
||||||
|
|
||||||
public class ReceiverParameterDescriptorImpl extends AbstractReceiverParameterDescriptor {
|
public class ReceiverParameterDescriptorImpl extends AbstractReceiverParameterDescriptor {
|
||||||
private final DeclarationDescriptor containingDeclaration;
|
private final DeclarationDescriptor containingDeclaration;
|
||||||
private final JetType type;
|
|
||||||
private final ReceiverValue value;
|
private final ReceiverValue value;
|
||||||
|
|
||||||
public ReceiverParameterDescriptorImpl(
|
public ReceiverParameterDescriptorImpl(@NotNull DeclarationDescriptor containingDeclaration, @NotNull ReceiverValue value) {
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
|
||||||
@NotNull JetType type,
|
|
||||||
@NotNull ReceiverValue value
|
|
||||||
) {
|
|
||||||
this.containingDeclaration = containingDeclaration;
|
this.containingDeclaration = containingDeclaration;
|
||||||
this.type = type;
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public JetType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ReceiverValue getValue() {
|
public ReceiverValue getValue() {
|
||||||
|
|||||||
@@ -115,6 +115,6 @@ public class DescriptorFactory {
|
|||||||
) {
|
) {
|
||||||
return receiverParameterType == null
|
return receiverParameterType == null
|
||||||
? NO_RECEIVER_PARAMETER
|
? NO_RECEIVER_PARAMETER
|
||||||
: new ReceiverParameterDescriptorImpl(owner, receiverParameterType, new ExtensionReceiver(owner, receiverParameterType));
|
: new ReceiverParameterDescriptorImpl(owner, new ExtensionReceiver(owner, receiverParameterType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user