Skip to content

Commit fe9cb2d

Browse files
committed
Fix runtime error in some of the BCL compilation tests on VS2015 caused by invalid writes to properties
1 parent f29071a commit fe9cb2d

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

JSIL/Transforms/ConvertPropertyAccessesToInvocations.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,24 @@ private JSExpression ConstructInvocation (
6565
if (!actualMethod.Reference.Name.Contains(correctName)) {
6666
var dt = originalMethod.Method.DeclaringType;
6767

68-
var actualMethodInfo = dt.Members.Values
69-
.OfType<MethodInfo>().FirstOrDefault(
70-
(m) => (
71-
m.Name.Contains(correctName) &&
72-
m.DeclaringType == originalMethod.Method.DeclaringType
73-
)
68+
var candidateMethodInfos = dt.Members.Values
69+
.OfType<MethodInfo>().Where(
70+
m => m.Name.Contains(correctName)
7471
);
7572

73+
var actualMethodInfo = candidateMethodInfos.FirstOrDefault(
74+
m => m.DeclaringType == originalMethod.Method.DeclaringType
75+
);
76+
77+
if (actualMethodInfo == null)
78+
return new JSUntranslatableExpression(String.Format(
79+
"{0} to property {1}::{2} could not be translated because {3} could not be found",
80+
pa.IsWrite ? "Write" : "Read",
81+
originalMethod.Reference.DeclaringType.FullName,
82+
pa.Property.Property.Name,
83+
correctName
84+
));
85+
7686
MethodReference actualMethodReference = actualMethodInfo.Member;
7787
if (originalMethod.Reference is GenericInstanceMethod) {
7888
throw new InvalidDataException("Reconstructing an invocation of a generic instance method? Shouldn't be possible.");

0 commit comments

Comments
 (0)