Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 95 additions & 28 deletions src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ private BoundDeconstructionAssignmentOperator BindDeconstructionAssignment(
return new BoundDeconstructionAssignmentOperator(
node,
DeconstructionVariablesAsTuple(left, checkedVariables, diagnostics, ignoreDiagnosticsFromTuple: true),
new BoundConversion(boundRHS.Syntax, boundRHS, Conversion.Deconstruction, @checked: false, explicitCastInCode: false, conversionGroupOpt: null,
constantValueOpt: null, type: type, hasErrors: true),
new BoundConversion(boundRHS.Syntax, boundRHS, Conversion.Deconstruction, @checked: false, explicitCastInCode: false,
conversionGroupOpt: null, InConversionGroupFlags.Unspecified, constantValueOpt: null, type: type, hasErrors: true),
resultIsUsed,
voidType,
hasErrors: true);
Expand Down Expand Up @@ -165,6 +165,7 @@ private BoundDeconstructionAssignmentOperator BindDeconstructionAssignment(
@checked: false,
explicitCastInCode: false,
conversionGroupOpt: null,
InConversionGroupFlags.Unspecified,
constantValueOpt: null,
type: returnType,
hasErrors: hasErrors)
Expand Down Expand Up @@ -309,7 +310,8 @@ private bool MakeDeconstructionConversion(
var operandPlaceholder = new BoundValuePlaceholder(syntax, ErrorTypeSymbol.UnknownResultType).MakeCompilerGenerated();
nestedConversions.Add((operandPlaceholder, new BoundConversion(syntax, operandPlaceholder, nestedConversion,
@checked: false, explicitCastInCode: false,
conversionGroupOpt: null, constantValueOpt: null,
conversionGroupOpt: null, InConversionGroupFlags.Unspecified,
constantValueOpt: null,
#pragma warning disable format
type: ErrorTypeSymbol.UnknownResultType) { WasCompilerGenerated = true }));
#pragma warning restore format
Expand All @@ -333,7 +335,7 @@ private bool MakeDeconstructionConversion(
{
var operandPlaceholder = new BoundValuePlaceholder(syntax, tupleOrDeconstructedTypes[i]).MakeCompilerGenerated();
nestedConversions.Add((operandPlaceholder, CreateConversion(syntax, operandPlaceholder,
nestedConversion, isCast: false, conversionGroupOpt: null, single.Type, diagnostics)));
nestedConversion, isCast: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, single.Type, diagnostics)));
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2833,7 +2833,7 @@ private BoundExpression BindCastCore(ExpressionSyntax node, BoundExpression oper
GenerateExplicitConversionErrors(diagnostics, node, conversion, operand, targetType);
}

return CreateConversion(node, operand, conversion, isCast: true, conversionGroupOpt: conversionGroup, wasCompilerGenerated: wasCompilerGenerated, destination: targetType, diagnostics: diagnostics, hasErrors: hasErrors | suppressErrors);
return CreateConversion(node, operand, conversion, isCast: true, conversionGroupOpt: conversionGroup, InConversionGroupFlags.Unspecified, wasCompilerGenerated: wasCompilerGenerated, destination: targetType, diagnostics: diagnostics, hasErrors: hasErrors | suppressErrors);
}

private void GenerateExplicitConversionErrors(
Expand Down Expand Up @@ -3579,7 +3579,7 @@ BoundExpression coerceArgument(
{
reportUnsafeIfNeeded(methodResult, diagnostics, argument, parameterTypeWithAnnotations);

coercedArgument = CreateConversion(argument.Syntax, argument, kind, isCast: false, conversionGroupOpt: null, parameterTypeWithAnnotations.Type, diagnostics);
coercedArgument = CreateConversion(argument.Syntax, argument, kind, isCast: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, parameterTypeWithAnnotations.Type, diagnostics);
}
else if (argument.Kind == BoundKind.OutVariablePendingInference)
{
Expand All @@ -3600,7 +3600,7 @@ BoundExpression coerceArgument(
if (argument is BoundTupleLiteral)
{
// CreateConversion reports tuple literal name mismatches, and constructs the expected pattern of bound nodes.
coercedArgument = CreateConversion(argument.Syntax, argument, kind, isCast: false, conversionGroupOpt: null, parameterTypeWithAnnotations.Type, diagnostics);
coercedArgument = CreateConversion(argument.Syntax, argument, kind, isCast: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, parameterTypeWithAnnotations.Type, diagnostics);
}
else
{
Expand Down Expand Up @@ -3765,6 +3765,7 @@ BoundExpression bindInterpolatedStringHandlerInMemberCall(
interpolatedStringConversion,
isCast: false,
conversionGroupOpt: null,
InConversionGroupFlags.Unspecified,
handlerType,
diagnostics);
}
Expand All @@ -3781,6 +3782,7 @@ BoundExpression bindInterpolatedStringHandlerInMemberCall(
interpolatedStringConversion,
isCast: false,
conversionGroupOpt: null,
InConversionGroupFlags.Unspecified,
wasCompilerGenerated: false,
handlerType,
diagnostics,
Expand All @@ -3796,6 +3798,7 @@ BoundExpression bindInterpolatedStringHandlerInMemberCall(
interpolatedStringConversion,
isCast: false,
conversionGroupOpt: null,
InConversionGroupFlags.Unspecified,
handlerType,
diagnostics);
}
Expand Down Expand Up @@ -3963,6 +3966,7 @@ BoundExpression bindInterpolatedStringHandlerInMemberCall(
@checked: CheckOverflowAtRuntime,
explicitCastInCode: false,
conversionGroupOpt: null,
InConversionGroupFlags.Unspecified,
constantValueOpt: null,
handlerType,
hasErrors || interpolatedString.HasErrors);
Expand Down Expand Up @@ -9116,6 +9120,7 @@ protected BoundExpression BindFieldAccess(
@checked: true,
explicitCastInCode: false,
conversionGroupOpt: null,
InConversionGroupFlags.Unspecified,
constantValueOpt: expr.ConstantValueOpt,
type: underlyingType);
}
Expand Down Expand Up @@ -9953,7 +9958,7 @@ private BoundExpression ConvertToArrayIndex(BoundExpression index, BindingDiagno
GenerateImplicitConversionError(diagnostics, node, failedConversion, index, int32);

// Suppress any additional diagnostics
return CreateConversion(node, index, failedConversion, isCast: false, conversionGroupOpt: null, destination: int32, diagnostics: BindingDiagnosticBag.Discarded);
return CreateConversion(node, index, failedConversion, isCast: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, destination: int32, diagnostics: BindingDiagnosticBag.Discarded);
}

return result;
Expand Down Expand Up @@ -10015,7 +10020,7 @@ private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr,
conversion = conversion.SetArrayIndexConversionForDynamic();
}

BoundExpression result = CreateConversion(expr.Syntax, expr, conversion, isCast: false, conversionGroupOpt: null, destination: targetType, diagnostics); // UNDONE: was cast?
BoundExpression result = CreateConversion(expr.Syntax, expr, conversion, isCast: false, conversionGroupOpt: null, InConversionGroupFlags.Unspecified, destination: targetType, diagnostics); // UNDONE: was cast?
Debug.Assert(result != null); // If this ever fails (it shouldn't), then put a null-check around the diagnostics update.

return result;
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,7 @@ BoundExpression bindDefaultArgument(SyntaxNode syntax, ParameterSymbol parameter
conversion,
isCast,
isCast ? new ConversionGroup(conversion, parameter.TypeWithAnnotations) : null,
InConversionGroupFlags.Unspecified,
parameterType,
diagnostics);
}
Expand Down Expand Up @@ -1880,6 +1881,7 @@ private BoundExpression CreateParamsCollection(SyntaxNode node, ParameterSymbol
@checked: CheckOverflowAtRuntime,
explicitCastInCode: false,
conversionGroupOpt: null,
InConversionGroupFlags.Unspecified,
constantValueOpt: null,
type: collectionType)
{ WasCompilerGenerated = true, IsParamsArrayOrCollection = true };
Expand Down
Loading