D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21602 - Invalid covariant parameter override allowed
Summary: Invalid covariant parameter override allowed
Status: RESOLVED DUPLICATE of issue 21538
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 major
Assignee: No Owner
URL:
Keywords: accepts-invalid, safe
Depends on:
Blocks:
 
Reported: 2021-02-01 20:49 UTC by Bolpat
Modified: 2021-03-31 00:59 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Bolpat 2021-02-01 20:49:05 UTC
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.
Comment 1 RazvanN 2021-02-02 11:29:41 UTC
Is this not a duplicate of: https://issues.dlang.org/show_bug.cgi?id=21538 ?
Comment 2 Bolpat 2021-03-31 00:59:28 UTC

*** This issue has been marked as a duplicate of issue 21538 ***