Skip to content

Commit

Permalink
Move logic into VisitConversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Nov 13, 2020
1 parent 92791ef commit e59706c
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5327,17 +5327,6 @@ private void VisitArgumentConversionAndInboundAssignmentsAndPreConditions(
case RefKind.In:
{
// Note: for lambda arguments, they will be converted in the context/state we saved for that argument
if (conversion is { Kind: ConversionKind.ImplicitUserDefined })
{
var argumentResultType = resultType.Type;
conversion = GenerateConversion(_conversions, argumentNoConversion, argumentResultType, parameterType.Type, fromExplicitCast: false, extensionMethodThisArgument: false);
if (!conversion.Exists && !argumentNoConversion.IsSuppressed)
{
Debug.Assert(argumentResultType is not null);
ReportNullabilityMismatchInArgument(argumentNoConversion.Syntax, argumentResultType, parameter, parameterType.Type, forOutput: false);
}
}

var stateAfterConversion = VisitConversion(
conversionOpt: conversionOpt,
conversionOperand: argumentNoConversion,
Expand Down Expand Up @@ -7062,6 +7051,16 @@ private TypeWithState VisitUserDefinedConversion(

TypeSymbol targetType = targetTypeWithNullability.Type;

if (parameterOpt is not null)
{
conversion = GenerateConversion(_conversions, conversionOperand, operandType.Type, targetTypeWithNullability.Type, fromExplicitCast: false, extensionMethodThisArgument: false);
if (!conversion.Exists && !conversionOperand.IsSuppressed)
{
Debug.Assert(operandType.Type is not null);
ReportNullabilityMismatchInArgument(conversionOperand.Syntax, operandType.Type, parameterOpt, targetTypeWithNullability.Type, forOutput: false);
}
}

// cf. Binder.CreateUserDefinedConversion
if (!conversion.IsValid)
{
Expand Down

0 comments on commit e59706c

Please sign in to comment.