summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModLoading
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-05-19 22:50:33 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-05-19 22:50:33 -0400
commitb54d892abf2bb5b7c05631d6f665b2a1d06529b1 (patch)
treeb53d79f17c015642962579040da81c7bf080f118 /src/SMAPI/Framework/ModLoading
parent1838842bbc2db2d1049c193b8650bd101ba4858f (diff)
downloadSMAPI-b54d892abf2bb5b7c05631d6f665b2a1d06529b1.tar.gz
SMAPI-b54d892abf2bb5b7c05631d6f665b2a1d06529b1.tar.bz2
SMAPI-b54d892abf2bb5b7c05631d6f665b2a1d06529b1.zip
fix rewriting declaring type for a generic method (#711)
Diffstat (limited to 'src/SMAPI/Framework/ModLoading')
-rw-r--r--src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
index 6aeb00ce..4c707248 100644
--- a/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs
@@ -122,7 +122,13 @@ namespace StardewModdingAPI.Framework.ModLoading.Framework
MethodReference methodRef = RewriteHelper.AsMethodReference(instruction);
if (methodRef != null)
{
- rewritten |= this.RewriteTypeReference(methodRef.DeclaringType, newType => methodRef.DeclaringType = newType);
+ rewritten |= this.RewriteTypeReference(methodRef.DeclaringType, newType =>
+ {
+ // note: generic methods are wrapped into a MethodSpecification which doesn't allow changing the
+ // declaring type directly. For our purposes we want to change all generic versions of a matched
+ // method anyway, so we can use GetElementMethod to get the underlying method here.
+ methodRef.GetElementMethod().DeclaringType = newType;
+ });
rewritten |= this.RewriteTypeReference(methodRef.ReturnType, newType => methodRef.ReturnType = newType);
foreach (var parameter in methodRef.Parameters)