|
| 1 | +From a396e60097a61cc7d0425583b004bce5c9b9ee72 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Brian Sullivan < [email protected]> |
| 3 | +Date: Sat, 28 Nov 2020 23:26:29 -0800 |
| 4 | +Subject: [PATCH] Fix issue 45183 Preserve the paramAttrs |
| 5 | + |
| 6 | +--- |
| 7 | + src/coreclr/src/ilasm/assembler.cpp | 14 ++++++++++---- |
| 8 | + 1 file changed, 10 insertions(+), 4 deletions(-) |
| 9 | + |
| 10 | +diff --git a/src/coreclr/src/ilasm/assembler.cpp b/src/coreclr/src/ilasm/assembler.cpp |
| 11 | +index 2e674db..b9bc13f 100644 |
| 12 | +--- a/src/coreclr/src/ilasm/assembler.cpp |
| 13 | ++++ b/src/coreclr/src/ilasm/assembler.cpp |
| 14 | +@@ -2715,18 +2715,24 @@ void Assembler::EmitGenericParamConstraints(int numTyPars, TyParDescr* pTyPars, |
| 15 | + |
| 16 | + if (currParamNumConstraints > 0) |
| 17 | + { |
| 18 | +- mdGenericParam tkGenericParam = pTyPars[paramIndex].Token(); |
| 19 | +- ULONG currNumConstraints = (ULONG) nConstraintsArr[paramIndex]; |
| 20 | +- mdToken* currConstraintArr = pConstraintsArr[paramIndex]; |
| 21 | ++ mdGenericParam tkGenericParam = pTyPars[paramIndex].Token(); |
| 22 | ++ DWORD paramAttrs = pTyPars[paramIndex].Attrs(); |
| 23 | ++ ULONG currNumConstraints = (ULONG) nConstraintsArr[paramIndex]; |
| 24 | ++ mdToken* currConstraintArr = pConstraintsArr[paramIndex]; |
| 25 | + mdGenericParamConstraint* currGPConstraintArr = pGPConstraintsArr[paramIndex]; |
| 26 | + |
| 27 | + // call SetGenericParamProps for each generic parameter that has a non-zero count of constraints |
| 28 | + // to record each generic parameters tyupe constraints. |
| 29 | + // |
| 30 | ++ // Pass the paramAttrs, these contain values in CorGenericParamAttr such as: |
| 31 | ++ // gpReferenceTypeConstraint = 0x0004, // type argument must be a reference type |
| 32 | ++ // gpNotNullableValueTypeConstraint = 0x0008, // type argument must be a value type but not Nullable |
| 33 | ++ // gpDefaultConstructorConstraint = 0x0010, // type argument must have a public default constructor |
| 34 | ++ // |
| 35 | + // This Metadata operation will also create a new GenericParamConstraint token |
| 36 | + // for each of the generic parameters type constraints. |
| 37 | + // |
| 38 | +- if (FAILED(m_pEmitter->SetGenericParamProps(tkGenericParam, 0, NULL, 0, currConstraintArr))) |
| 39 | ++ if (FAILED(m_pEmitter->SetGenericParamProps(tkGenericParam, paramAttrs, NULL, 0, currConstraintArr))) |
| 40 | + { |
| 41 | + report->error("Failed in SetGenericParamProp"); |
| 42 | + } |
| 43 | +-- |
| 44 | +1.8.3.1 |
| 45 | + |
0 commit comments