diff options
author | Vitek Karas <10670590+vitek-karas@users.noreply.github.com> | 2022-07-14 22:38:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-14 22:38:12 +0300 |
commit | 072ebe7c115e80bf2555bb5f02049379e6bf9722 (patch) | |
tree | a9bc2688acedc1ed692873297e01c397850486a5 /src/linker/Linker.Dataflow/CompilerGeneratedState.cs | |
parent | e2b3a925b1ee6c55f9b95540647ce8362fe9ee44 (diff) |
Fix a bug with null value passed to annotated parameter on attribute (#2894)
This also makes small tweaks to help with linker->AOT sync.
Diffstat (limited to 'src/linker/Linker.Dataflow/CompilerGeneratedState.cs')
-rw-r--r-- | src/linker/Linker.Dataflow/CompilerGeneratedState.cs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/linker/Linker.Dataflow/CompilerGeneratedState.cs b/src/linker/Linker.Dataflow/CompilerGeneratedState.cs index 2802e6703..c99968f1d 100644 --- a/src/linker/Linker.Dataflow/CompilerGeneratedState.cs +++ b/src/linker/Linker.Dataflow/CompilerGeneratedState.cs @@ -102,7 +102,7 @@ namespace Mono.Linker.Dataflow /// up and find the nearest containing user type. Returns the nearest user type, /// or null if none was found. /// </summary> - TypeDefinition? PopulateCacheForType (TypeDefinition type) + TypeDefinition? GetCompilerGeneratedStateForType (TypeDefinition type) { // Look in the declaring type if this is a compiler-generated type (state machine or display class). // State machines can be emitted into display classes, so we may also need to go one more level up. @@ -183,7 +183,7 @@ namespace Mono.Linker.Dataflow } // Already warned above if multiple methods map to the same type // Fill in null for argument providers now, the real providers will be filled in later - _ = _generatedTypeToTypeArgumentInfo.TryAdd (stateMachineType, new TypeArgumentInfo (method, null)); + _generatedTypeToTypeArgumentInfo[stateMachineType] = new TypeArgumentInfo (method, null); } } @@ -292,6 +292,7 @@ namespace Mono.Linker.Dataflow if (typeRef is null) { return; } + for (int i = 0; i < typeRef.GenericArguments.Count; i++) { var typeArg = typeRef.GenericArguments[i]; // Start with the existing parameters, in case we can't find the mapped one @@ -321,6 +322,7 @@ namespace Mono.Linker.Dataflow typeArgs[i] = userAttrs; } + _generatedTypeToTypeArgumentInfo[generatedType] = typeInfo with { OriginalAttributes = typeArgs }; } } @@ -356,7 +358,7 @@ namespace Mono.Linker.Dataflow if (IsNestedFunctionOrStateMachineMember (method)) return false; - var typeToCache = PopulateCacheForType (method.DeclaringType); + var typeToCache = GetCompilerGeneratedStateForType (method.DeclaringType); if (typeToCache is null) return false; @@ -371,7 +373,7 @@ namespace Mono.Linker.Dataflow { Debug.Assert (CompilerGeneratedNames.IsGeneratedType (generatedType.Name)); - var typeToCache = PopulateCacheForType (generatedType); + var typeToCache = GetCompilerGeneratedStateForType (generatedType); if (typeToCache is null) return null; @@ -407,7 +409,7 @@ namespace Mono.Linker.Dataflow // sourceType is a state machine type, or the type containing a lambda or local function. // Search all methods to find the one which points to the type as its // state machine implementation. - var typeToCache = PopulateCacheForType (sourceType); + var typeToCache = GetCompilerGeneratedStateForType (sourceType); if (typeToCache is null) return false; |