Here is a sample code that triggers an error: // File I.d module I; import Base; interface I { } interface SubI : I { } // File Base.d module Base; import I; class Base { I create() { return null; } } class Derived : Base { SubI create() { return null; } } Compilation options: "dmd I.d" Note that "dmd Base.d" compiles okay.
And here is an error message: Base.d(15): function Base.Derived.create of type SubI() overrides but is not covariant with Base.Base.create of type I()
The error can fixed by removing "import Base;" from the I.d, but unfortunately I can't do this in my application because interfaces have methods that accept and return references to Base and Derived: interface I { void doStuff(Base b); } interface SubI : I { void doStuff(Derived b); } A possible solution is to merge them into a single file (which is not acceptable). You should also have a proper file order to compile them at once: dmd Base I // okay dmd I Base // fails to compile Rising its severity until I find a workaround.
This sounds related to old bug 125. And it occurs in the D1 line too. Also rewriting the summary line as the one that was there was confusing.
Created attachment 456 [details] better detection if a base class is forward referenced The current implementation (as of DMD 2.032) defers covariance analysis only if the base class is not yet semantically analysed and it is not an interface. The patch refines this condition by testing whether the class has any forward referenced base classes or interfaces.
The patch breaks this code: class UA { A29 f() { return null; } } class UB : UA { B29 f() { return null; } } class A29 { } class B29 : A29 { }
Partial apply of patch: http://www.dsource.org/projects/dmd/changeset/638
Oh, it's only been tested on interfaces. ClassDeclaration::isBaseInfoComplete() is broken, class Object doesn't need a base class: int ClassDeclaration::isBaseInfoComplete() { if (!baseClass) return ident == Id::Object; ...
This now fails: class UA { A29 f() { return null; } } class UB : UA { B29 f() { return null; } } class A29 { } class B29 : A29 { }
NOTE: these tests are part of the dmd svn depot these days.. so if you check it out from dsource you can run them yourself cd $(dir}/dmd/src make cd ../test make It's only known to work on linux, though ought to work on any posix system and will need work to work on windows. Any fixes that are required I'd be happy to fold in.
http://www.dsource.org/projects/dmd/changeset/650
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル