diff --git a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs index c93e19a9173e4f..f0ca74dde53e57 100644 --- a/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs +++ b/src/coreclr/tools/Common/Compiler/NativeAotNameMangler.cs @@ -302,6 +302,23 @@ private string ComputeMangledTypeName(TypeDesc type) case TypeFlags.Pointer: mangledName = GetMangledTypeName(((PointerType)type).ParameterType) + NestMangledName("Pointer"); break; + case TypeFlags.FunctionPointer: + // TODO: need to also encode calling convention (or all modopts?) + var fnPtrType = (FunctionPointerType)type; + mangledName = "__FnPtr" + EnterNameScopeSequence; + mangledName += GetMangledTypeName(fnPtrType.Signature.ReturnType); + + mangledName += EnterNameScopeSequence; + for (int i = 0; i < fnPtrType.Signature.Length; i++) + { + if (i != 0) + mangledName += DelimitNameScopeSequence; + mangledName += GetMangledTypeName(fnPtrType.Signature[i]); + } + mangledName += ExitNameScopeSequence; + + mangledName += ExitNameScopeSequence; + break; default: // Case of a generic type. If `type' is a type definition we use the type name // for mangling, otherwise we use the mangling of the type and its generic type diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableFieldNode.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableFieldNode.cs index c5bd4945050676..4f4cd477d44e3b 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableFieldNode.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableFieldNode.cs @@ -85,7 +85,11 @@ public override IEnumerable GetStaticDependencies(NodeFacto // Runtime reflection stack needs to obtain the type handle of the field // (but there's no type handles for function pointers) - if (!_field.FieldType.IsFunctionPointer) + TypeDesc fieldTypeToCheck = _field.FieldType; + while (fieldTypeToCheck.IsParameterizedType) + fieldTypeToCheck = ((ParameterizedType)fieldTypeToCheck).ParameterType; + + if (!fieldTypeToCheck.IsFunctionPointer) dependencies.Add(factory.MaximallyConstructableType(_field.FieldType.NormalizeInstantiation()), "Type of the field"); return dependencies;