Skip to content

Commit

Permalink
Merge pull request #43221 from Dilhasha/mock-field-fix
Browse files Browse the repository at this point in the history
Ignore type check for private fields in object mocking
  • Loading branch information
Dilhasha authored Aug 2, 2024
2 parents 1caf979 + 2c13b17 commit 50eaace
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 50eaace

Please sign in to comment.