From: Mikko Rasa Date: Sun, 12 Mar 2023 13:18:10 +0000 (+0200) Subject: Use a covariant return type for get_real_target in FileTarget X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e7370dbd2bde63d0d12f73d8606b3992954f40ce;p=builder.git Use a covariant return type for get_real_target in FileTarget --- diff --git a/source/lib/filetarget.h b/source/lib/filetarget.h index 64128d6..4a969b8 100644 --- a/source/lib/filetarget.h +++ b/source/lib/filetarget.h @@ -37,6 +37,8 @@ public: /// Changes the mtime of the target to the current time. void touch(); + FileTarget *get_real_target() override { return this; } + protected: void check_rebuild() override; diff --git a/source/lib/installedfile.cpp b/source/lib/installedfile.cpp index bf542b0..78a7c3a 100644 --- a/source/lib/installedfile.cpp +++ b/source/lib/installedfile.cpp @@ -54,7 +54,7 @@ void InstalledFile::set_symlink(const FS::Path &l) builder.get_vfs().register_path(link, this); } -Target *InstalledFile::get_real_target() +FileTarget *InstalledFile::get_real_target() { return source.get_real_target(); } diff --git a/source/lib/installedfile.h b/source/lib/installedfile.h index e9dfe17..3037982 100644 --- a/source/lib/installedfile.h +++ b/source/lib/installedfile.h @@ -29,7 +29,7 @@ public: const Msp::FS::Path &get_symlink() const { return link; } - Target *get_real_target() override; + FileTarget *get_real_target() override; private: void check_rebuild() override; diff --git a/source/lib/objectfile.cpp b/source/lib/objectfile.cpp index 63a8e6b..46ec607 100644 --- a/source/lib/objectfile.cpp +++ b/source/lib/objectfile.cpp @@ -52,7 +52,7 @@ void ObjectFile::find_dependencies(FileTarget &tgt, vector &header { tgt.prepare(); - FileTarget *rtgt = dynamic_cast(tgt.get_real_target()); + FileTarget *rtgt = tgt.get_real_target(); Dependencies deps_to_add = rtgt->get_transitive_dependencies(); if(rtgt!=&tgt) {