Prohibit val/vars/modifiers on secondary constructor parameter
#KT-6962 Fixed
This commit is contained in:
@@ -587,6 +587,7 @@ public interface Errors {
|
||||
DiagnosticFactory1<PsiElement, JetKeywordToken> VAL_OR_VAR_ON_LOOP_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetKeywordToken> VAL_OR_VAR_ON_FUN_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetKeywordToken> VAL_OR_VAR_ON_CATCH_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<PsiElement, JetKeywordToken> VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
// Backing fields
|
||||
|
||||
|
||||
+1
@@ -265,6 +265,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(VAL_OR_VAR_ON_LOOP_PARAMETER, "''{0}'' on loop parameter is not allowed", TO_STRING);
|
||||
MAP.put(VAL_OR_VAR_ON_FUN_PARAMETER, "''{0}'' on function parameter is not allowed", TO_STRING);
|
||||
MAP.put(VAL_OR_VAR_ON_CATCH_PARAMETER, "''{0}'' on catch parameter is not allowed", TO_STRING);
|
||||
MAP.put(VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER, "''{0}'' on secondary constructor parameter is not allowed", TO_STRING);
|
||||
|
||||
MAP.put(INITIALIZATION_USING_BACKING_FIELD_CUSTOM_SETTER,
|
||||
"This property has a custom setter, so initialization using backing field required", NAME);
|
||||
|
||||
@@ -326,8 +326,12 @@ class FunctionDescriptorResolver(
|
||||
}
|
||||
}
|
||||
|
||||
if (functionDescriptor !is ConstructorDescriptor) {
|
||||
DescriptorResolver.checkParameterHasNoValOrVar(trace, valueParameter, VAL_OR_VAR_ON_FUN_PARAMETER)
|
||||
if (functionDescriptor !is ConstructorDescriptor || !functionDescriptor.isPrimary()) {
|
||||
val isConstructor = functionDescriptor is ConstructorDescriptor
|
||||
DescriptorResolver.checkParameterHasNoValOrVar(
|
||||
trace, valueParameter,
|
||||
if (isConstructor) VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER else VAL_OR_VAR_ON_FUN_PARAMETER
|
||||
)
|
||||
DescriptorResolver.checkParameterHasNoModifier(trace, valueParameter)
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user