Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackson Schuster <36744439+jtschuster@users.noreply.github.com>2022-11-10 20:54:58 +0300
committerGitHub <noreply@github.com>2022-11-10 20:54:58 +0300
commit9c993bf401377209cd7b4e84b60deab5e4f421a2 (patch)
treec021e1dbffd49e7a859f98020456fbdc76049261
parent73e08af5da4d32f3f4f34a8fc680b773b875bcda (diff)
Use ContainingType instead of ContainingSymbol in GetReferenceKind (#3107)HEADmain
-rw-r--r--src/ILLink.RoslynAnalyzer/TrimAnalysis/ParameterProxy.cs4
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/MethodByRefParameterDataFlow.cs46
2 files changed, 48 insertions, 2 deletions
diff --git a/src/ILLink.RoslynAnalyzer/TrimAnalysis/ParameterProxy.cs b/src/ILLink.RoslynAnalyzer/TrimAnalysis/ParameterProxy.cs
index 6ee65cbb9..fe01aeaf5 100644
--- a/src/ILLink.RoslynAnalyzer/TrimAnalysis/ParameterProxy.cs
+++ b/src/ILLink.RoslynAnalyzer/TrimAnalysis/ParameterProxy.cs
@@ -17,7 +17,7 @@ namespace ILLink.Shared.TypeSystemProxy
public partial ReferenceKind GetReferenceKind () =>
IsImplicitThis
- ? ((ITypeSymbol) Method.Method.ContainingSymbol).IsValueType
+ ? Method.Method.ContainingType.IsValueType
? ReferenceKind.Ref
: ReferenceKind.None
: Method.Method.Parameters[MetadataIndex].RefKind switch {
@@ -54,4 +54,4 @@ namespace ILLink.Shared.TypeSystemProxy
public bool IsTypeOf (WellKnownType type) => ParameterType.IsTypeOf (type);
}
-} \ No newline at end of file
+}
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodByRefParameterDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodByRefParameterDataFlow.cs
index 27dda5a8c..bce67302e 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodByRefParameterDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodByRefParameterDataFlow.cs
@@ -37,6 +37,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
Type nullType4 = null;
TestAssigningToRefParameter_Mismatch (nullType4, ref nullType4);
TestPassingRefsWithImplicitThis ();
+ LocalMethodsAndLambdas.Test ();
}
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
@@ -190,6 +191,51 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
}
+ static class LocalMethodsAndLambdas
+ {
+ static ref Type GetTypeRefWithoutAnnotations () { throw null; }
+
+ [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
+ static ref Type GetTypeRefWithMethods () { throw null; }
+
+ [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicFields)]
+ static ref Type GetTypeRefWithMethodsAndFields () { throw null; }
+
+ [ExpectedWarning ("IL2067", "t", "InnerMethodWithDam")]
+ [ExpectedWarning ("IL2067", "tWithMethodsAndFields", "InnerMethodWithDam")]
+ [ExpectedWarning ("IL2072", nameof (GetTypeRefWithoutAnnotations), "InnerMethodWithDam")]
+ [ExpectedWarning ("IL2068", nameof (GetTypeRefWithMethodsAndFields), "InnerMethodWithDam")]
+ static void MethodWithLocaMethodWithDam (Type t, [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type tWithMethods, [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicFields)] Type tWithMethodsAndFields)
+ {
+ // 2067
+ InnerMethodWithDam (ref t);
+
+ // Okay
+ InnerMethodWithDam (ref tWithMethods);
+
+ // 2067 (but parameter of inner method targets parameter of outer method)
+ InnerMethodWithDam (ref tWithMethodsAndFields);
+
+ // 2072
+ InnerMethodWithDam (ref GetTypeRefWithoutAnnotations ());
+
+ // No warn
+ InnerMethodWithDam (ref GetTypeRefWithMethods ());
+
+ // 2068
+ InnerMethodWithDam (ref GetTypeRefWithMethodsAndFields ());
+
+ void InnerMethodWithDam ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] ref Type typeWithMethods)
+ {
+ }
+ }
+
+ public static void Test ()
+ {
+ MethodWithLocaMethodWithDam (null, null, null);
+ }
+ }
+
#region InheritsFromType
class InheritsFromType : Type
{