C#: Fix sorting for generic types when reloading assemblies.

This commit is contained in:
Zae 2024-01-26 18:00:46 +08:00
parent 4b6ad34988
commit 18599c0935
2 changed files with 9 additions and 2 deletions

View file

@ -697,19 +697,25 @@ struct CSharpScriptDepSort {
// Shouldn't happen but just in case... // Shouldn't happen but just in case...
return false; return false;
} }
const Script *I = B->get_base_script().ptr(); const CSharpScript *I = get_base_script(B.ptr()).ptr();
while (I) { while (I) {
if (I == A.ptr()) { if (I == A.ptr()) {
// A is a base of B // A is a base of B
return true; return true;
} }
I = I->get_base_script().ptr(); I = get_base_script(I).ptr();
} }
// A isn't a base of B // A isn't a base of B
return false; return false;
} }
// Special fix for constructed generic types.
Ref<CSharpScript> get_base_script(const CSharpScript *p_script) const {
Ref<CSharpScript> base_script = p_script->base_script;
return base_script.is_valid() && !base_script->class_name.is_empty() ? base_script : nullptr;
}
}; };
void CSharpLanguage::reload_all_scripts() { void CSharpLanguage::reload_all_scripts() {

View file

@ -60,6 +60,7 @@ class CSharpScript : public Script {
friend class CSharpInstance; friend class CSharpInstance;
friend class CSharpLanguage; friend class CSharpLanguage;
friend struct CSharpScriptDepSort;
bool tool = false; bool tool = false;
bool global_class = false; bool global_class = false;