Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mmews committed Jul 11, 2024
1 parent 88cd6a8 commit c98ecf5
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,9 @@ private void checkMembers(TypeRef leftTypeRef, StructuralMembersTriple triple, S
+ " failed: readable field requires a readable field or a getter in subtype.");
}
}
}
break;
}

// For any ~w~ right members.
case STRUCTURAL_WRITE_ONLY_FIELDS: {

Expand All @@ -404,8 +405,8 @@ private void checkMembers(TypeRef leftTypeRef, StructuralMembersTriple triple, S
+ " failed: writable field requires a writable field or a setter in subtype.");
}
}
}
break;
}

// For any ~i~ right members.
case STRUCTURAL_FIELD_INITIALIZER: {
Expand All @@ -429,28 +430,29 @@ private void checkMembers(TypeRef leftTypeRef, StructuralMembersTriple triple, S
+ " failed: non-optional writable field requires a readable field or a getter in subtype.");
}
}
}
break;
}

default: {
default:

// If the left member is ~r~, ~w~ and/or ~i~ type.
if (STRUCTURAL_READ_ONLY_FIELDS == leftStrategy || STRUCTURAL_WRITE_ONLY_FIELDS == leftStrategy
|| STRUCTURAL_FIELD_INITIALIZER == leftStrategy) {

// If right is writable field, a getter/setter pair is mandatory on the left.
if (isWriteableField(rightMember)) {
if (!isGetterSetterPair(leftMember, leftOtherAccessor)) {
info.wrongMembers.add(rightMember.getName()
+ " failed: writable field requires a getter/setter pair in subtype.");
}
}
} else
// If right is readable, we require an explicit getter.
if (READABLE_FIELDS_PREDICATE.apply(rightMember)) {
if (!(GETTERS_PREDICATE.apply(leftMember) || GETTERS_PREDICATE.apply(leftOtherAccessor))) {
info.wrongMembers
.add(rightMember.getName() + " failed: read-only field requires a getter in subtype.");
}
}
} else
// If there is a setter on the right, then we need a setter on the left.
if (SETTERS_PREDICATE.apply(rightMember)) {
if (!(SETTERS_PREDICATE.apply(leftMember) || SETTERS_PREDICATE.apply(leftOtherAccessor))) {
Expand Down Expand Up @@ -483,8 +485,9 @@ private void checkMembers(TypeRef leftTypeRef, StructuralMembersTriple triple, S
}

}
break;
}
}

}

/** Returns with {@code true} iff the the arguments are a getter-setter accessor pair. */
Expand Down

0 comments on commit c98ecf5

Please sign in to comment.