Deep substitution now doesn't lose variance info.
This commit is contained in:
@@ -71,14 +71,13 @@ public class SubstitutionUtils {
|
||||
|
||||
for (int i = 0; i < arguments.size(); i++) {
|
||||
TypeProjection argument = arguments.get(i);
|
||||
TypeParameterDescriptor typeParameterDescriptor = parameters.get(i);
|
||||
TypeParameterDescriptor parameter = parameters.get(i);
|
||||
|
||||
JetType substitute = substitutor.substitute(argument.getType(), Variance.INVARIANT);
|
||||
TypeProjection substitute = substitutor.substitute(argument);
|
||||
assert substitute != null;
|
||||
TypeProjection substitutedTypeProjection = new TypeProjection(argument.getProjectionKind(), substitute);
|
||||
substitution.put(typeParameterDescriptor.getTypeConstructor(), substitutedTypeProjection);
|
||||
substitution.put(parameter.getTypeConstructor(), substitute);
|
||||
if (fullSubstitution != null) {
|
||||
fullSubstitution.put(typeParameterDescriptor.getTypeConstructor(), substitutedTypeProjection);
|
||||
fullSubstitution.put(parameter.getTypeConstructor(), substitute);
|
||||
}
|
||||
}
|
||||
if (KotlinBuiltIns.getInstance().isNothingOrNullableNothing(context)) return;
|
||||
|
||||
@@ -125,12 +125,18 @@ public class TypeSubstitutor {
|
||||
|
||||
@Nullable
|
||||
public JetType substitute(@NotNull JetType type, @NotNull Variance howThisTypeIsUsed) {
|
||||
TypeProjection projection = substitute(new TypeProjection(howThisTypeIsUsed, type));
|
||||
return projection == null ? null : projection.getType();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TypeProjection substitute(@NotNull TypeProjection typeProjection) {
|
||||
if (isEmpty()) {
|
||||
return type;
|
||||
return typeProjection;
|
||||
}
|
||||
|
||||
try {
|
||||
return unsafeSubstitute(new TypeProjection(howThisTypeIsUsed, type), 0).getType();
|
||||
return unsafeSubstitute(typeProjection, 0);
|
||||
} catch (SubstitutionException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user