Skip to content

Commit

Permalink
Ignore type check for private fields in object mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilhasha committed Aug 2, 2024
1 parent 7db2e07 commit 2c13b17
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,9 @@ private static BError validateFunctionSignatures(MethodType func,
private static BError validateField(Map.Entry<String, Field> mockField, Map<String, Field> fieldMap) {
for (Map.Entry<String, Field> field : fieldMap.entrySet()) {
if (field.getKey().equals(mockField.getKey())) {
if (TypeChecker.checkIsType(field.getValue().getFieldType(), mockField.getValue().getFieldType())) {
// Ignore type checking if the field is private
if (SymbolFlags.isFlagOn(field.getValue().getFlags(), SymbolFlags.PRIVATE) ||
TypeChecker.checkIsType(field.getValue().getFieldType(), mockField.getValue().getFieldType())) {
return null;
} else {
String detail = "incompatible field type '" + mockField.getValue().getFieldType() + "' provided " +
Expand Down

0 comments on commit 2c13b17

Please sign in to comment.