Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions modules/mono/csharp_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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() {
Expand Down
1 change: 1 addition & 0 deletions modules/mono/csharp_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class CSharpScript : public Script {

friend class CSharpInstance;
friend class CSharpLanguage;
friend struct CSharpScriptDepSort;

bool tool = false;
bool global_class = false;
Expand Down
Loading