Ensure the base type and interfaces of generic instance types are instantiated#549
Ensure the base type and interfaces of generic instance types are instantiated#549ds5678 wants to merge 1 commit into
Conversation
f0f137a to
5f32b62
Compare
Coverage Report for CI Build 28810477125Coverage increased (+0.1%) to 36.238%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
|
Branch has conflicts that I don't have permission to resolve. |
5f32b62 to
db19c06
Compare
| if (_underConstruction2 != null && _underConstruction2.TryGetValue((genericType.AppContext, genericType, genericArgumentsList), out var partial)) | ||
| return partial; | ||
|
|
||
| return genericType.AppContext.GenericInstanceTypesByConstruction |
There was a problem hiding this comment.
This means we have 2 separate caches now, GenericInstanceTypesByIl2CppType, and this one. Which means you can have 2 instances of the exact same GIT, both considered canonical, in 2 different dictionaries, and break reference equality, which we do rely on in some places. Needs to be unified somehow.
|
|
||
| namespace Cpp2IL.Core.Model.Contexts; | ||
|
|
||
| internal readonly record struct GenericArgumentList(List<TypeAnalysisContext> Arguments) |
There was a problem hiding this comment.
This list is a) exposed publicly, b) used for hash code calculation, and c) the same reference is exposed as GenericArguments on the GIT. GenericArgumentList is used as part of the key in the GenericInstanceTypesByConstruction dict. Creates kind of a footgun because someone could change a GIT's arguments, which would change the key of an item in the dictionary which can break shit. E.g. if you have a Dictionary<string, string>, change it to Dictionary<string, object>, then call GetOrCreate to try to get a Dictionary<string, object>, the key won't be found in the dict because its hashcode has changed, and you'll get a second (or potentially third, when combined with the other issue) instance for the same GIT.
This aligns with behavior for
DeclaringType.This pull request depends on #575.