Minor. Better parameters/variables naming.
This commit is contained in:
+23
-23
@@ -279,37 +279,37 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if assignment from ActualType to TargetType is erased.
|
* Check if assignment from supertype to subtype is erased.
|
||||||
* It is an error in "is" statement and warning in "as".
|
* It is an error in "is" statement and warning in "as".
|
||||||
*/
|
*/
|
||||||
public static boolean isCastErased(JetType actualType, JetType targetType, JetTypeChecker typeChecker) {
|
public static boolean isCastErased(JetType supertype, JetType subtype, JetTypeChecker typeChecker) {
|
||||||
if (!(targetType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
|
if (!(subtype.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
|
||||||
// TODO: what if it is TypeParameterDescriptor?
|
// TODO: what if it is TypeParameterDescriptor?
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not crash on error types
|
// do not crash on error types
|
||||||
if (ErrorUtils.isErrorType(actualType) || ErrorUtils.isErrorType(targetType)) {
|
if (ErrorUtils.isErrorType(supertype) || ErrorUtils.isErrorType(subtype)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TypeParameterDescriptor> actualTypeParameters = actualType.getConstructor().getParameters();
|
List<TypeParameterDescriptor> superTypeParameters = supertype.getConstructor().getParameters();
|
||||||
{
|
{
|
||||||
Multimap<TypeConstructor, TypeProjection> typeSubstitutionMap =
|
Multimap<TypeConstructor, TypeProjection> subtypeSubstitutionMap =
|
||||||
SubstitutionUtils.buildDeepSubstitutionMultimap(targetType);
|
SubstitutionUtils.buildDeepSubstitutionMultimap(subtype);
|
||||||
|
|
||||||
for (int i = 0; i < actualTypeParameters.size(); i++) {
|
for (int i = 0; i < superTypeParameters.size(); i++) {
|
||||||
TypeProjection actualTypeArgument = actualType.getArguments().get(i);
|
TypeProjection superTypeArgument = supertype.getArguments().get(i);
|
||||||
TypeParameterDescriptor actualTypeParameter = actualTypeParameters.get(i);
|
TypeParameterDescriptor superTypeParameter = superTypeParameters.get(i);
|
||||||
|
|
||||||
if (actualTypeParameter.isReified()) {
|
if (superTypeParameter.isReified()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<TypeProjection> substituted = typeSubstitutionMap.get(actualTypeParameter.getTypeConstructor());
|
Collection<TypeProjection> substituted = subtypeSubstitutionMap.get(superTypeParameter.getTypeConstructor());
|
||||||
for (TypeProjection substitutedProjection : substituted) {
|
for (TypeProjection substitutedProjection : substituted) {
|
||||||
//if (!substitutedProjection.getType().equals(actualTypeArgument.getType())) {
|
//if (!substitutedProjection.getType().equals(superTypeArgument.getType())) {
|
||||||
if (!typeChecker.isSubtypeOf(actualTypeArgument.getType(), substitutedProjection.getType())) { // TODO hides error
|
if (!typeChecker.isSubtypeOf(superTypeArgument.getType(), substitutedProjection.getType())) { // TODO hides error
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,31 +317,31 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
JetType targetTypeCleared = TypeUtils.makeUnsubstitutedType(
|
JetType subtypeCleared = TypeUtils.makeUnsubstitutedType(
|
||||||
(ClassDescriptor) targetType.getConstructor().getDeclarationDescriptor(), null);
|
(ClassDescriptor) subtype.getConstructor().getDeclarationDescriptor(), null);
|
||||||
|
|
||||||
Multimap<TypeConstructor, TypeProjection> clearTypeSubstitutionMap =
|
Multimap<TypeConstructor, TypeProjection> clearTypeSubstitutionMap =
|
||||||
SubstitutionUtils.buildDeepSubstitutionMultimap(targetTypeCleared);
|
SubstitutionUtils.buildDeepSubstitutionMultimap(subtypeCleared);
|
||||||
|
|
||||||
Set<JetType> clearSubstituted = new HashSet<JetType>();
|
Set<JetType> clearSubstituted = new HashSet<JetType>();
|
||||||
|
|
||||||
for (TypeParameterDescriptor actualTypeParameter : actualTypeParameters) {
|
for (TypeParameterDescriptor superTypeParameter : superTypeParameters) {
|
||||||
Collection<TypeProjection> substituted = clearTypeSubstitutionMap.get(actualTypeParameter.getTypeConstructor());
|
Collection<TypeProjection> substituted = clearTypeSubstitutionMap.get(superTypeParameter.getTypeConstructor());
|
||||||
for (TypeProjection substitutedProjection : substituted) {
|
for (TypeProjection substitutedProjection : substituted) {
|
||||||
clearSubstituted.add(substitutedProjection.getType());
|
clearSubstituted.add(substitutedProjection.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TypeParameterDescriptor> targetTypeParameters = targetType.getConstructor().getParameters();
|
List<TypeParameterDescriptor> subTypeParameters = subtype.getConstructor().getParameters();
|
||||||
for (int i = 0; i < targetTypeParameters.size(); i++) {
|
for (int i = 0; i < subTypeParameters.size(); i++) {
|
||||||
TypeParameterDescriptor typeParameter = targetTypeParameters.get(i);
|
TypeParameterDescriptor typeParameter = subTypeParameters.get(i);
|
||||||
|
|
||||||
if (typeParameter.isReified()) {
|
if (typeParameter.isReified()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "is List<*>"
|
// "is List<*>"
|
||||||
TypeProjection typeArgument = targetType.getArguments().get(i);
|
TypeProjection typeArgument = subtype.getArguments().get(i);
|
||||||
if (typeArgument.equals(SubstitutionUtils.makeStarProjection(typeParameter))) {
|
if (typeArgument.equals(SubstitutionUtils.makeStarProjection(typeParameter))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user