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:
Victor Petukhov
2021-09-23 18:11:50 +03:00
parent 3530840da3
commit 0cb56be14f
17 changed files with 368 additions and 2 deletions
@@ -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")