www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21602] New: Invalid covariant parameter override allowed


          Issue ID: 21602
           Summary: Invalid covariant parameter override allowed
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: qs.il.paperinik gmail.com

interface SinkString
    void toString(void delegate(string) sink);

class Aggregate : SinkString
    override void toString(void delegate(string)  safe sink)  safe
        sink("I'm an Aggreate!");

Here, void delegate(string)  safe is not a super-type of void delegate(string)
which it would need to be to be sound by the Liskov substitution principle. To
the contrary, it allows passing  system `sink`s to an Aggregate object through
a SinkString reference.

Feb 01 2021