From 1fb7bd7fd889941c818cba6b1eb277e90e61dc9c Mon Sep 17 00:00:00 2001 From: Daniel Kozak Date: Wed, 26 Jul 2017 15:40:54 +0200 Subject: [PATCH] Fix issue 17686: [REG2.075.0] Covariant return types doesn't work with override in some cases --- src/ddmd/mtype.d | 2 +- test/compilable/fix17686.d | 45 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 test/compilable/fix17686.d diff --git a/src/ddmd/mtype.d b/src/ddmd/mtype.d index 9f4186c67b2c..013b0c5e3a5f 100644 --- a/src/ddmd/mtype.d +++ b/src/ddmd/mtype.d @@ -775,7 +775,7 @@ extern (C++) abstract class Type : RootObject // If t1n is forward referenced: ClassDeclaration cd = (cast(TypeClass)t1n).sym; - if (cd.semanticRun < PASSsemanticdone) + if (cd.semanticRun < PASSsemanticdone && cd.baseok < BASEOKdone) cd.semantic(null); if (!cd.isBaseInfoComplete()) { diff --git a/test/compilable/fix17686.d b/test/compilable/fix17686.d new file mode 100644 index 000000000000..db82252ff4a4 --- /dev/null +++ b/test/compilable/fix17686.d @@ -0,0 +1,45 @@ +/* REQUIRED_ARGS: + * PERMUTE_ARGS: + */ + +// https://issues.dlang.org/show_bug.cgi?id=17686 + +interface INode +{ + @property INode parentNode(); + @property IDocument ownerDocument(); +} +interface IDocument: INode {} +interface IEntityReference: INode {} + +class DOMImplementation(T) +{ + abstract class Node: INode + { + override + { + @property Node parentNode() { return null; } + @property Document ownerDocument() { return null; } + } + + @property bool readonly() { return true; } + } + abstract class NodeWithChildren: Node {} + + class Document: NodeWithChildren, IDocument {} + + class EntityReference: NodeWithChildren, IEntityReference + { + override + { + @property bool readonly() { return true; } + } + } + +} + +void main() +{ + alias aaa = DOMImplementation!string; +} +