diff options
-rw-r--r-- | src/SMAPI/Framework/ModLoading/Framework/RecursiveRewriter.cs | 8 |
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) |