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