Approximate types for lambda literals before serialization

This commit is contained in:
Mikhail Zarechenskiy
2020-05-29 01:14:28 +03:00
parent 366ed7d4ca
commit 0ab9b3639b
12 changed files with 224 additions and 15 deletions
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.descriptors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeSubstitution;
import java.util.Collection;
@@ -93,6 +94,9 @@ public interface CallableMemberDescriptor extends CallableDescriptor, MemberDesc
@NotNull
CopyBuilder<D> setPreserveSourceElement();
@NotNull
CopyBuilder<D> setReturnType(@NotNull KotlinType type);
@Nullable
D build();
}
@@ -105,6 +105,7 @@ public interface FunctionDescriptor extends CallableMemberDescriptor {
CopyBuilder<D> setTypeParameters(@NotNull List<TypeParameterDescriptor> parameters);
@NotNull
@Override
CopyBuilder<D> setReturnType(@NotNull KotlinType type);
@NotNull
@@ -264,6 +264,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
private ReceiverParameterDescriptor dispatchReceiverParameter = PropertyDescriptorImpl.this.dispatchReceiverParameter;
private List<TypeParameterDescriptor> newTypeParameters = null;
private Name name = getName();
private KotlinType returnType = getType();
@NotNull
@Override
@@ -286,6 +287,13 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
return this;
}
@NotNull
@Override
public CopyBuilder<PropertyDescriptor> setReturnType(@NotNull KotlinType type) {
returnType = type;
return this;
}
@NotNull
@Override
public CopyConfiguration setModality(@NotNull Modality modality) {
@@ -386,7 +394,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
originalTypeParameters, copyConfiguration.substitution, substitutedDescriptor, substitutedTypeParameters
);
KotlinType originalOutType = getType();
KotlinType originalOutType = copyConfiguration.returnType;
KotlinType outType = substitutor.substitute(originalOutType, Variance.OUT_VARIANCE);
if (outType == null) {
return null; // TODO : tell the user that the property was projected out