Invariant sharing with Eiffel's keyword `like`
<p>In Eiffel, it is possible to specify a type with an '<a href="https://www.eiffel.org/doc/eiffel/ET%3A%20Inheritance#Anchored_Declarations" rel="nofollow noreferrer">anchored declaration</a>'.</p>

<p>I wonder if the relevant invariants in the class also apply to an anchored declaration:</p>

<pre><code>class C

feature

    f: INTEGER
        do
            ... Do something ...
        end

    g: like f
        do
            ... Do some other thing ...
        end

invariant
    0 &lt; f
    -- 0 &lt; g  &lt;-- Does this pop into existence?
end
</code></pre>

<p>I didn't see this written anywhere, and I <em>think</em> it's not the case. It would be convenient, sometimes, to avoid defining yet another type, but I think that would restrict the usefulness of anchored declarations in all other cases.</p>