[Issue 21602] New: Invalid covariant parameter override allowed
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Feb  1 20:49:05 UTC 2021
    
    
  
https://issues.dlang.org/show_bug.cgi?id=21602
          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 at puremagic.com
          Reporter: qs.il.paperinik at 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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list