diff --git a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/strict/check/InvocationParamIntersectionCheck.java b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/strict/check/InvocationParamIntersectionCheck.java index 2777eb0d..9b36256c 100644 --- a/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/strict/check/InvocationParamIntersectionCheck.java +++ b/bundles/com.e1c.v8codestyle.bsl/src/com/e1c/v8codestyle/bsl/strict/check/InvocationParamIntersectionCheck.java @@ -30,6 +30,7 @@ import org.eclipse.xtext.resource.IResourceServiceProvider; import com._1c.g5.v8.dt.bsl.common.IBslPreferences; import com._1c.g5.v8.dt.bsl.model.BslPackage; +import com._1c.g5.v8.dt.bsl.model.EmptyExpression; import com._1c.g5.v8.dt.bsl.model.Expression; import com._1c.g5.v8.dt.bsl.model.FeatureAccess; import com._1c.g5.v8.dt.bsl.model.FeatureEntry; @@ -160,7 +161,8 @@ public class InvocationParamIntersectionCheck Expression param = inv.getParams().get(i); List sorceTypes = computeTypes(param, actualEnvs); - boolean isUndefined = param == null || param instanceof UndefinedLiteral || isUndefinedType(sorceTypes); + boolean isUndefined = param == null || param instanceof UndefinedLiteral || param instanceof EmptyExpression + || isUndefinedType(sorceTypes); List targetTypes = Collections.emptyList(); boolean isIntersect = false; @@ -174,7 +176,8 @@ public class InvocationParamIntersectionCheck iterator.remove(); continue; } - boolean isDefaultValue = targetParams.get(i).isDefaultValue(); + Parameter parameter = targetParams.get(i); + boolean isDefaultValue = parameter.isDefaultValue(); if (isDefaultValue && isUndefined) { diff --git a/tests/com.e1c.v8codestyle.bsl.itests/resources/strict/invocation-parameter-type-intersect-with-default.bsl b/tests/com.e1c.v8codestyle.bsl.itests/resources/strict/invocation-parameter-type-intersect-with-default.bsl new file mode 100644 index 00000000..a21768d5 --- /dev/null +++ b/tests/com.e1c.v8codestyle.bsl.itests/resources/strict/invocation-parameter-type-intersect-with-default.bsl @@ -0,0 +1,25 @@ +// @strict-types + +Procedure NonComplaint() Export + + Result = StrConcat(, ); + +EndProcedure + +// Parameters: +// Parameters - Structure: +// * Key1 - Number - has type for key +Procedure Complaint(Parameters) Export + + Result = InformationRegisters["MyName"].SliceFirst(, Parameters); + +EndProcedure + +// Parameters: +// Parameters - Structure: +// * Key1 - Number - has type for key +Procedure Complaint2(Parameters) Export + + Result = InformationRegisters["MyName"].SliceFirst(Undefined, Parameters); + +EndProcedure diff --git a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/strict/check/itests/CommonModuleStrictTypesTest.java b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/strict/check/itests/CommonModuleStrictTypesTest.java index a8720c43..c5d5422b 100644 --- a/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/strict/check/itests/CommonModuleStrictTypesTest.java +++ b/tests/com.e1c.v8codestyle.bsl.itests/src/com/e1c/v8codestyle/bsl/strict/check/itests/CommonModuleStrictTypesTest.java @@ -392,6 +392,30 @@ public class CommonModuleStrictTypesTest } + /** + * Test of {@link InvocationParamIntersectionCheck} that invokable method parameter type intersects + * with caller type, and skip checking if method has default value parameters. + * + * @throws Exception the exception + */ + @Test + public void testInvocationParamIntersectionCheckWithDefault() throws Exception + { + + String checkId = "invocation-parameter-type-intersect"; + String resouceName = "invocation-parameter-type-intersect-with-default"; + + Module module = updateAndGetModule(resouceName); + + List markers = getMarters(checkId, module); + + assertEquals(1, markers.size()); + + Marker marker = markers.get(0); + assertEquals("5", marker.getExtraInfo().get("line")); + + } + private List getMarters(String checkId, Module module) { String id = module.eResource().getURI().toPlatformString(true);