Skip to content

Commit

Permalink
Add check not using @key in derived structures (#154)
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware authored Jul 29, 2024
1 parent 23dfeeb commit 0e8ce7e
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.eprosima.idl.parser.exception.ParseException;
import com.eprosima.idl.parser.exception.RuntimeGenerationException;
import com.eprosima.idl.parser.tree.Annotation;
import com.eprosima.idl.parser.typecode.StructTypeCode;

public abstract class MemberedTypeCode extends TypeCode
{
Expand Down Expand Up @@ -246,6 +247,11 @@ public boolean addMember(
throw new ParseException(null, "Error in member " + member.getName() +
": @" + Annotation.key_str + " and @" + Annotation.optional_str + " annotations are incompatible.");
}
if (member.isAnnotationKey() && this instanceof StructTypeCode && null != ((StructTypeCode)this).getInheritance())
{
throw new ParseException(null, "Error in member " + member.getName() +
": @" + Annotation.key_str + " cannot be used in a derived type.");
}
if (member.isAnnotationId() && member.isAnnotationHashid())
{
throw new ParseException(null, "Error in member " + member.getName() +
Expand Down

0 comments on commit 0e8ce7e

Please sign in to comment.