Skip to content

Commit

Permalink
Don't overwrite interpolation data during nullable rewrite.
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Jul 22, 2021
1 parent e007e2d commit 0f97ce1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ private UncommonData(ConstantValue? constantValue, MethodSymbol? method, TypeSym
IsUnconvertedInterpolatedStringAddition = isUnconvertedInterpolatedStringAddition;
InterpolatedStringHandlerData = interpolatedStringHandlerData;
}

public UncommonData WithUpdatedMethod(MethodSymbol? method)
{
if ((object?)method == Method)
{
return this;
}

return new UncommonData(ConstantValue, method, ConstrainedToType, OriginalUserDefinedOperatorsOpt, IsUnconvertedInterpolatedStringAddition, InterpolatedStringHandlerData);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private BoundNode VisitBinaryOperatorBase(BoundBinaryOperatorBase binaryOperator
stack.Push(currentBinary);
currentBinary = currentBinary.Left as BoundBinaryOperatorBase;
}
while (currentBinary is object);
while (currentBinary is not null);

Debug.Assert(stack.Count > 0);
var leftChild = (BoundExpression)Visit(stack.Peek().Left);
Expand All @@ -56,7 +56,7 @@ private BoundNode VisitBinaryOperatorBase(BoundBinaryOperatorBase binaryOperator
{
BoundBinaryOperator binary => binary.Update(
binary.OperatorKind,
BoundBinaryOperator.UncommonData.CreateIfNeeded(binary.ConstantValue, GetUpdatedSymbol(binary, binary.Method), binary.ConstrainedToType, binary.OriginalUserDefinedOperatorsOpt),
binary.Data?.WithUpdatedMethod(GetUpdatedSymbol(binary, binary.Method)),
binary.ResultKind,
leftChild,
right,
Expand Down

0 comments on commit 0f97ce1

Please sign in to comment.