"field": control of accessor parameter name shadowing, test

This commit is contained in:
Mikhail Glukhikh
2015-09-21 10:57:05 +03:00
parent 4f3e3610a0
commit ad302fcfba
6 changed files with 25 additions and 0 deletions
@@ -379,6 +379,7 @@ public interface Errors {
// General
DiagnosticFactory1<PsiElement, String> NAME_SHADOWING = DiagnosticFactory1.create(WARNING, PositioningStrategies.FOR_REDECLARATION);
DiagnosticFactory0<PsiElement> ACCESSOR_PARAMETER_NAME_SHADOWING = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<JetExpression> TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM = DiagnosticFactory0.create(ERROR);
@@ -114,6 +114,7 @@ public class DefaultErrorMessages {
MAP.put(REDECLARATION, "Redeclaration: {0}", STRING);
MAP.put(NAME_SHADOWING, "Name shadowed: {0}", STRING);
MAP.put(ACCESSOR_PARAMETER_NAME_SHADOWING, "Accessor parameter name 'field' is shadowed by backing field variable");
MAP.put(TYPE_MISMATCH, "Type mismatch: inferred type is {1} but {0} was expected", RENDER_TYPE, RENDER_TYPE);
MAP.put(INCOMPATIBLE_MODIFIERS, "Modifier ''{0}'' is incompatible with ''{1}''", TO_STRING, TO_STRING);
@@ -779,6 +779,11 @@ public class BodyResolver {
SyntheticFieldDescriptor fieldDescriptor = new SyntheticFieldDescriptor(accessorDescriptor, property);
WritableScopeStorage innerScopeStorage = (WritableScopeStorage) innerScope;
innerScopeStorage.addVariableOrClassDescriptor(fieldDescriptor);
for (JetParameter parameter : function.getValueParameters()) {
if (SyntheticFieldDescriptor.NAME.equals(parameter.getNameAsName())) {
trace.report(Errors.ACCESSOR_PARAMETER_NAME_SHADOWING.on(parameter));
}
}
}
DataFlowInfo dataFlowInfo = null;