diff options
author | Michal Strehovský <MichalStrehovsky@users.noreply.github.com> | 2017-06-11 05:44:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-11 05:44:59 +0300 |
commit | 42fd6d0fc5d695afeb79745936afd6a1ce8b74c8 (patch) | |
tree | 6d0fee9011a3597789f349b3a181359c8cfe2921 | |
parent | 208de3dd1aa5f0de33c44bc024dc5122eb455208 (diff) |
Fix open delegates to instance methods on valuetypes (#3857)
-rw-r--r-- | src/Common/src/TypeSystem/IL/DelegateInfo.cs | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/Common/src/TypeSystem/IL/DelegateInfo.cs b/src/Common/src/TypeSystem/IL/DelegateInfo.cs index fd3227729..bcf1f2afe 100644 --- a/src/Common/src/TypeSystem/IL/DelegateInfo.cs +++ b/src/Common/src/TypeSystem/IL/DelegateInfo.cs @@ -119,12 +119,30 @@ namespace Internal.IL { TypeDesc firstParam = delegateSignature[0]; - bool generateOpenInstanceMethod = true; + bool generateOpenInstanceMethod; - if (firstParam.IsValueType || - (!firstParam.IsDefType && !firstParam.IsSignatureVariable) /* no arrays, pointers, byrefs, etc. */) + switch (firstParam.Category) { - generateOpenInstanceMethod = false; + case TypeFlags.Pointer: + case TypeFlags.FunctionPointer: + generateOpenInstanceMethod = false; + break; + + case TypeFlags.ByRef: + firstParam = ((ByRefType)firstParam).ParameterType; + generateOpenInstanceMethod = firstParam.IsSignatureVariable || firstParam.IsValueType; + break; + + case TypeFlags.Array: + case TypeFlags.SzArray: + case TypeFlags.SignatureTypeVariable: + generateOpenInstanceMethod = true; + break; + + default: + Debug.Assert(firstParam.IsDefType); + generateOpenInstanceMethod = !firstParam.IsValueType; + break; } if (generateOpenInstanceMethod) |