added 'getCurrentSubstitutor' to ConstraintSystem
which returns DON_CARE type projection for unknown type parameters
This commit is contained in:
@@ -350,7 +350,7 @@ public class CallResolver {
|
||||
for (ValueArgument valueArgument : resolvedValueArgument.getArguments()) {
|
||||
if (!JetPsiUtil.isFunctionLiteralWithoutDeclaredParameterTypes(valueArgument.getArgumentExpression())) continue;
|
||||
|
||||
addConstraintForValueArgument(valueArgument, valueParameterDescriptor, constraintsSystem.getResultingSubstitutor(),
|
||||
addConstraintForValueArgument(valueArgument, valueParameterDescriptor, constraintsSystem.getCurrentSubstitutor(),
|
||||
constraintsSystem, context);
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -121,4 +121,11 @@ public interface ConstraintsSystem {
|
||||
*/
|
||||
@NotNull
|
||||
TypeSubstitutor getResultingSubstitutor();
|
||||
|
||||
/**
|
||||
* Returns a current result of solving the constraint system (mapping from the type variable to the resulting type projection).
|
||||
* If there is no information for type parameter, returns type projection for DONT_CARE type.
|
||||
*/
|
||||
@NotNull
|
||||
TypeSubstitutor getCurrentSubstitutor();
|
||||
}
|
||||
|
||||
+16
-2
@@ -39,10 +39,16 @@ public class ConstraintsSystemImpl implements ConstraintsSystem {
|
||||
private final Map<TypeParameterDescriptor, TypeConstraintsImpl> typeParameterConstraints = Maps.newLinkedHashMap();
|
||||
private final Set<ConstraintPosition> errorConstraintPositions = Sets.newHashSet();
|
||||
private final TypeSubstitutor resultingSubstitutor;
|
||||
private final TypeSubstitutor currentSubstitutor;
|
||||
private boolean hasErrorInConstrainingTypes;
|
||||
|
||||
public ConstraintsSystemImpl() {
|
||||
this.resultingSubstitutor = TypeSubstitutor.create(new TypeSubstitution() {
|
||||
this.resultingSubstitutor = createTypeSubstitutorWithDefaultForUnknownTypeParameter(null);
|
||||
this.currentSubstitutor = createTypeSubstitutorWithDefaultForUnknownTypeParameter(new TypeProjection(DONT_CARE));
|
||||
}
|
||||
|
||||
private TypeSubstitutor createTypeSubstitutorWithDefaultForUnknownTypeParameter(@Nullable final TypeProjection defaultTypeProjection) {
|
||||
return TypeSubstitutor.create(new TypeSubstitution() {
|
||||
@Override
|
||||
public TypeProjection get(TypeConstructor key) {
|
||||
DeclarationDescriptor declarationDescriptor = key.getDeclarationDescriptor();
|
||||
@@ -54,7 +60,9 @@ public class ConstraintsSystemImpl implements ConstraintsSystem {
|
||||
DONT_CARE.getConstructor()))) {
|
||||
return new TypeProjection(value);
|
||||
}
|
||||
return new TypeProjection(DONT_CARE);
|
||||
if (typeParameterConstraints.containsKey(descriptor)) {
|
||||
return defaultTypeProjection;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -231,4 +239,10 @@ public class ConstraintsSystemImpl implements ConstraintsSystem {
|
||||
public TypeSubstitutor getResultingSubstitutor() {
|
||||
return resultingSubstitutor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TypeSubstitutor getCurrentSubstitutor() {
|
||||
return currentSubstitutor;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user