Bug 21602 – Invalid covariant parameter override allowed

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-02-01T20:49:05Z
Last change time
2021-03-31T00:59:28Z
Keywords
accepts-invalid, safe
Assigned to
No Owner
Creator
Bolpat

Comments

Comment #0 by qs.il.paperinik — 2021-02-01T20:49:05Z
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 by razvan.nitu1305 — 2021-02-02T11:29:41Z
Comment #2 by qs.il.paperinik — 2021-03-31T00:59:28Z
*** This issue has been marked as a duplicate of issue 21538 ***