Have "in type" for java fields to be able to check that type in assignment positions (against rhs' type)
^KT-46727 Fixed
This commit is contained in:
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.descriptors;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -65,4 +66,7 @@ public interface PropertyDescriptor extends VariableDescriptorWithAccessors, Cal
|
||||
@NotNull
|
||||
@Override
|
||||
CopyBuilder<? extends PropertyDescriptor> newCopyBuilder();
|
||||
|
||||
@Nullable
|
||||
KotlinType getInType();
|
||||
}
|
||||
|
||||
+15
@@ -108,6 +108,15 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
isExpect, isActual, isExternal, isDelegated);
|
||||
}
|
||||
|
||||
public void setInType(@NotNull KotlinType inType) {
|
||||
/* Do nothing as the corresponding setter is generated by default */
|
||||
}
|
||||
|
||||
@Override
|
||||
public KotlinType getInType() {
|
||||
return setter != null ? setter.getValueParameters().get(0).getType() : null;
|
||||
}
|
||||
|
||||
public void setType(
|
||||
@NotNull KotlinType outType,
|
||||
@ReadOnly @NotNull List<? extends TypeParameterDescriptor> typeParameters,
|
||||
@@ -400,6 +409,12 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
return null; // TODO : tell the user that the property was projected out
|
||||
}
|
||||
|
||||
KotlinType inType = substitutor.substitute(originalOutType, Variance.IN_VARIANCE);
|
||||
|
||||
if (inType != null) {
|
||||
substitutedDescriptor.setInType(inType);
|
||||
}
|
||||
|
||||
ReceiverParameterDescriptor substitutedDispatchReceiver;
|
||||
ReceiverParameterDescriptor dispatchReceiver = copyConfiguration.dispatchReceiverParameter;
|
||||
if (dispatchReceiver != null) {
|
||||
|
||||
Reference in New Issue
Block a user