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:
+14
@@ -37,6 +37,8 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
@Nullable
|
||||
private final Pair<UserDataKey<?>, ?> singleUserData;
|
||||
|
||||
private KotlinType inType = null;
|
||||
|
||||
protected JavaPropertyDescriptor(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@@ -172,6 +174,18 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
(!TypeEnhancementKt.hasEnhancedNullability(type) || KotlinBuiltIns.isString(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInType(@NotNull KotlinType inType) {
|
||||
this.inType = inType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable KotlinType getInType() {
|
||||
PropertySetterDescriptor setter = getSetter();
|
||||
KotlinType setterType = setter != null ? setter.getValueParameters().get(0).getType() : null;
|
||||
return setterType != null ? setterType : inType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -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