diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index ef24dc35ca..f17552d8ab 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -697,19 +697,25 @@ struct CSharpScriptDepSort { // Shouldn't happen but just in case... return false; } - const Script *I = B->get_base_script().ptr(); + const CSharpScript *I = get_base_script(B.ptr()).ptr(); while (I) { if (I == A.ptr()) { // A is a base of B return true; } - I = I->get_base_script().ptr(); + I = get_base_script(I).ptr(); } // A isn't a base of B return false; } + + // Special fix for constructed generic types. + Ref get_base_script(const CSharpScript *p_script) const { + Ref 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() { diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 310cb81929..918776a6ba 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -60,6 +60,7 @@ class CSharpScript : public Script { friend class CSharpInstance; friend class CSharpLanguage; + friend struct CSharpScriptDepSort; bool tool = false; bool global_class = false;