Diagnostics corrected for smart cast impossible

This commit is contained in:
Mikhail Glukhikh
2015-11-16 15:09:24 +03:00
parent b4fe62e53e
commit 03287d5d66
5 changed files with 13 additions and 13 deletions
@@ -33,10 +33,10 @@ class DataFlowValue(val id: Any?, val type: KotlinType, val kind: DataFlowValue.
STABLE_VALUE("stable"),
// Member value with open / custom getter
// Smart casts are not safe
MEMBER_VALUE_WITH_GETTER("custom getter", "member value that has open or custom getter"),
PROPERTY_WITH_GETTER("custom getter", "property that has open or custom getter"),
// Protected / public member value from another module
// Smart casts are not safe
ALIEN_PUBLIC_VALUE("alien public", "public API member value declared in different module"),
ALIEN_PUBLIC_PROPERTY("alien public", "public API property declared in different module"),
// Local variable not yet captured by a changing closure
// Smart casts are safe but possible changes in loops / closures ahead must be taken into account
PREDICTABLE_VARIABLE("predictable", "local variable that can be changed since the check in a loop"),
@@ -45,7 +45,7 @@ class DataFlowValue(val id: Any?, val type: KotlinType, val kind: DataFlowValue.
UNPREDICTABLE_VARIABLE("unpredictable", "local variable that is captured by a changing closure"),
// Member variable regardless of its visibility
// Smart casts are not safe
MEMBER_VARIABLE("member", "member variable that can be changed from another thread"),
MUTABLE_PROPERTY("member", "mutable property that could have been changed by this time"),
// Some complex expression
// Smart casts are not safe
OTHER("other", "complex expression");
@@ -377,13 +377,13 @@ public class DataFlowValueFactory {
}
private static Kind propertyKind(@NotNull PropertyDescriptor propertyDescriptor, @Nullable ModuleDescriptor usageModule) {
if (propertyDescriptor.isVar()) return MEMBER_VARIABLE;
if (!isFinal(propertyDescriptor)) return MEMBER_VALUE_WITH_GETTER;
if (!hasDefaultGetter(propertyDescriptor)) return MEMBER_VALUE_WITH_GETTER;
if (propertyDescriptor.isVar()) return MUTABLE_PROPERTY;
if (!isFinal(propertyDescriptor)) return PROPERTY_WITH_GETTER;
if (!hasDefaultGetter(propertyDescriptor)) return PROPERTY_WITH_GETTER;
if (!invisibleFromOtherModules(propertyDescriptor)) {
ModuleDescriptor declarationModule = DescriptorUtils.getContainingModule(propertyDescriptor);
if (usageModule == null || !usageModule.equals(declarationModule)) {
return ALIEN_PUBLIC_VALUE;
return ALIEN_PUBLIC_PROPERTY;
}
}
return STABLE_VALUE;
@@ -400,7 +400,7 @@ public class DataFlowValueFactory {
}
if (!(variableDescriptor instanceof LocalVariableDescriptor) && !(variableDescriptor instanceof ParameterDescriptor)) return OTHER;
if (!variableDescriptor.isVar()) return STABLE_VALUE;
if (variableDescriptor instanceof SyntheticFieldDescriptor) return MEMBER_VARIABLE;
if (variableDescriptor instanceof SyntheticFieldDescriptor) return MUTABLE_PROPERTY;
// Local variable classification: PREDICTABLE or UNPREDICTABLE
PreliminaryDeclarationVisitor preliminaryVisitor =