Overloaded operations containers and extended languages

A library (KernelF but it’s not important which one it is) defines some types and some operations and relationships between them. In particular, it defines some overloaded operations containers to specify that e.g. EqualsExpression can be applied to two EnumTypes as long as they are for the same enum.

My project is extending the library and defining a ‘nothing’ type which is a subtype of every type. To express this fact we added a replacement rule (much like in the documentation). However, now when I write an expression comparing a ‘nothing’ to an enum, my overload rule gets activated, tries to find out the enum of ‘nothing’ (treating it as an EnumType), and fails.
I get a warning about ‘conflicting rules for overloaded operation type’ because rules for other unrelated types are applied, e.g. (RealType, RealType) and (RealType, RationalType), and so on.

Attempting to fix this by creating an overloaded operation rule for (NothingType, Type) and (Type, NothingType) doesn’t work. Is there some way to specify that some overloaded operations rules should have precedence over other rules? What could I do to make this work? This is in MPS 2025.1.

The way overloaded operations rules work, is for every rule for a specific operation, such as a binary operation, typechecker tries to match its left and right operand types with the types provided in the rule. If the option “is exact” is set to false, types are compared using subtyping relation, and that includes subtyping by replacement rules. If “is exact” is true, types are compared using exact matching. Moreover, rules declaring either of their operand types as “exact” have higher priority.

The suggested fix would be to declare overloaded operation rule(s) for all of the operations with left or right operand matching <Nothing> exactly, and the other operand matching <Any> and its subtypes. These rules would be consulted first, and that should avoid the conflict.

It doesn’t seem to work this way, even with ‘is exact’ I am getting the message about conflicting rules. I will try to create a small reproducer and submit a bug.