diff options
author | Sven Boemer <sbomer@gmail.com> | 2022-04-29 03:39:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-29 03:39:47 +0300 |
commit | 848f9d48961945b9a0236ae7ff7b687c7d4abe42 (patch) | |
tree | bd44d44cea1742e2870dbb3d53ce79faf43f46e0 /test | |
parent | adeebaa36095abffad414d473b039d36a45cb37e (diff) |
Don't throw on InstanceReference assignment (#2772)
Diffstat (limited to 'test')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs index bd3a2b35d..245490b37 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs @@ -24,6 +24,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow PropagateToThis (); PropagateToThisWithGetters (); PropagateToThisWithSetters (); + AssignToThis (); TestAnnotationOnNonTypeMethod (); TestUnknownThis (); @@ -83,6 +84,13 @@ namespace Mono.Linker.Tests.Cases.DataFlow return null; } + static void AssignToThis () + { + var s = new StructType (); + s.AssignToThis (); + s.AssignToThisCaptured (); + } + static void TestAnnotationOnNonTypeMethod () { var t = new NonTypeType (); @@ -148,6 +156,24 @@ namespace Mono.Linker.Tests.Cases.DataFlow { } } + + struct StructType + { + int f; + public StructType (int f) => this.f = f; + + public void AssignToThis () + { + // Not relevant for dataflow, but this should not crash the analyzer. + this = new StructType (); + } + + public void AssignToThisCaptured () + { + // Not relevant for dataflow, but this should not crash the analyzer. + this = string.Empty.Length == 0 ? new StructType (1) : new StructType (2); + } + } } } |