Minor. Renamed variables where 'projection kind' term should be used instead of 'variance'.
This commit is contained in:
+14
-14
@@ -116,36 +116,36 @@ public class SignaturesPropagation {
|
||||
boolean covariantPosition = effectiveProjectionKind == TypeCheckingProcedure.EnrichedProjectionKind.OUT;
|
||||
|
||||
JetType type = modifyReturnTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, covariantPosition);
|
||||
Variance variance = calculateArgumentVarianceFromSuper(argument, projectionsFromSuper);
|
||||
Variance projectionKind = calculateArgumentProjectionKindFromSuper(argument, projectionsFromSuper);
|
||||
|
||||
resultArguments.add(new TypeProjection(variance, type));
|
||||
resultArguments.add(new TypeProjection(projectionKind, type));
|
||||
}
|
||||
return resultArguments;
|
||||
}
|
||||
|
||||
private static Variance calculateArgumentVarianceFromSuper(TypeProjection argument, List<TypeProjection> projectionsFromSuper) {
|
||||
Set<Variance> variancesInSuper = Sets.newHashSet();
|
||||
private static Variance calculateArgumentProjectionKindFromSuper(TypeProjection argument, List<TypeProjection> projectionsFromSuper) {
|
||||
Set<Variance> projectionKindsInSuper = Sets.newHashSet();
|
||||
for (TypeProjection projection : projectionsFromSuper) {
|
||||
variancesInSuper.add(projection.getProjectionKind());
|
||||
projectionKindsInSuper.add(projection.getProjectionKind());
|
||||
}
|
||||
|
||||
Variance defaultVariance = argument.getProjectionKind();
|
||||
if (variancesInSuper.size() == 0) {
|
||||
return defaultVariance;
|
||||
Variance defaultProjectionKind = argument.getProjectionKind();
|
||||
if (projectionKindsInSuper.size() == 0) {
|
||||
return defaultProjectionKind;
|
||||
}
|
||||
else if (variancesInSuper.size() == 1) {
|
||||
Variance varianceInSuper = variancesInSuper.iterator().next();
|
||||
if (defaultVariance == Variance.INVARIANT || defaultVariance == varianceInSuper) {
|
||||
return varianceInSuper;
|
||||
else if (projectionKindsInSuper.size() == 1) {
|
||||
Variance projectionKindInSuper = projectionKindsInSuper.iterator().next();
|
||||
if (defaultProjectionKind == Variance.INVARIANT || defaultProjectionKind == projectionKindInSuper) {
|
||||
return projectionKindInSuper;
|
||||
}
|
||||
else {
|
||||
// TODO report error
|
||||
return defaultVariance;
|
||||
return defaultProjectionKind;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TODO report error
|
||||
return defaultVariance;
|
||||
return defaultProjectionKind;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -123,30 +123,30 @@ class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
|
||||
TypeProjection argument = arguments.get(i);
|
||||
JetType alternativeType = computeType(argumentAlternativeTypeElement, argument.getType(), originalToAltTypeParameters);
|
||||
Variance variance = argument.getProjectionKind();
|
||||
Variance altVariance;
|
||||
Variance projectionKind = argument.getProjectionKind();
|
||||
Variance altProjectionKind;
|
||||
if (type instanceof JetUserType) {
|
||||
JetTypeProjection typeProjection = ((JetUserType) type).getTypeArguments().get(i);
|
||||
switch (typeProjection.getProjectionKind()) {
|
||||
case IN:
|
||||
altVariance = Variance.IN_VARIANCE;
|
||||
altProjectionKind = Variance.IN_VARIANCE;
|
||||
break;
|
||||
case OUT:
|
||||
altVariance = Variance.OUT_VARIANCE;
|
||||
altProjectionKind = Variance.OUT_VARIANCE;
|
||||
break;
|
||||
case STAR:
|
||||
throw new AlternativeSignatureMismatchException("Star projection is not available in alternative signatures");
|
||||
default:
|
||||
altVariance = Variance.INVARIANT;
|
||||
altProjectionKind = Variance.INVARIANT;
|
||||
}
|
||||
if (altVariance != variance && variance != Variance.INVARIANT) {
|
||||
throw new AlternativeSignatureMismatchException("Variance mismatch, actual: %s, in alternative signature: %s", variance, altVariance);
|
||||
if (altProjectionKind != projectionKind && projectionKind != Variance.INVARIANT) {
|
||||
throw new AlternativeSignatureMismatchException("Variance mismatch, actual: %s, in alternative signature: %s", projectionKind, altProjectionKind);
|
||||
}
|
||||
}
|
||||
else {
|
||||
altVariance = variance;
|
||||
altProjectionKind = projectionKind;
|
||||
}
|
||||
altArguments.add(new TypeProjection(altVariance, alternativeType));
|
||||
altArguments.add(new TypeProjection(altProjectionKind, alternativeType));
|
||||
}
|
||||
|
||||
TypeConstructor typeConstructor;
|
||||
|
||||
Reference in New Issue
Block a user