diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs index 972800d4fee55..b9b55cf887db8 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs @@ -553,7 +553,7 @@ private BoundExpression BindExpressionInternal(ExpressionSyntax node, Diagnostic return BindDefaultExpression((DefaultExpressionSyntax)node, diagnostics); case SyntaxKind.DefaultLiteral: - return new BoundDefaultOperator((DefaultLiteralSyntax)node, ConstantValue.DefaultLiteral, type: null); + return BindDefaultLiteral((DefaultLiteralSyntax)node); case SyntaxKind.TypeOfExpression: return BindTypeOf((TypeOfExpressionSyntax)node, diagnostics); @@ -656,6 +656,11 @@ private BoundExpression BindExpressionInternal(ExpressionSyntax node, Diagnostic } } + private static BoundExpression BindDefaultLiteral(DefaultLiteralSyntax node) + { + return new BoundDefaultLiteral(node, ConstantValue.DefaultLiteral, type: null); + } + private BoundExpression BindTupleExpression(TupleExpressionSyntax node, DiagnosticBag diagnostics) { SeparatedSyntaxList arguments = node.Arguments; @@ -970,7 +975,7 @@ internal static ConstantValue GetConstantSizeOf(TypeSymbol type) private BoundExpression BindDefaultExpression(DefaultExpressionSyntax node, DiagnosticBag diagnostics) { TypeSymbol type = this.BindType(node.Type, diagnostics); - return new BoundDefaultOperator(node, type); + return new BoundDefaultLiteral(node, type); } /// @@ -5008,7 +5013,7 @@ private BoundExpression BindMemberAccessWithBoundLeft( private static void WarnOnAccessOfOffDefault(SyntaxNode node, BoundExpression boundLeft, DiagnosticBag diagnostics) { - if (boundLeft != null && boundLeft.Kind == BoundKind.DefaultOperator && boundLeft.ConstantValue == ConstantValue.Null) + if (boundLeft != null && boundLeft.Kind == BoundKind.DefaultLiteral && boundLeft.ConstantValue == ConstantValue.Null) { Error(diagnostics, ErrorCode.WRN_DotOnDefault, node, boundLeft.Type); } diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs index b64a4cdecc6b8..88f5868b4940d 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs @@ -3176,7 +3176,7 @@ private BoundStatement BindReturn(ReturnStatementSyntax syntax, DiagnosticBag di var interactiveInitializerMethod = this.ContainingMemberOrLambda as SynthesizedInteractiveInitializerMethod; if (interactiveInitializerMethod != null) { - arg = new BoundDefaultOperator(interactiveInitializerMethod.GetNonNullSyntaxNode(), interactiveInitializerMethod.ResultType); + arg = new BoundDefaultLiteral(interactiveInitializerMethod.GetNonNullSyntaxNode(), interactiveInitializerMethod.ResultType); } } diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs index 0415972e4b517..454abea10c92c 100644 --- a/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs +++ b/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/ConversionsBase.cs @@ -815,8 +815,8 @@ private Conversion ClassifyImplicitBuiltInConversionFromExpression(BoundExpressi } break; - case BoundKind.DefaultOperator: - var defaultExpression = (BoundDefaultOperator)sourceExpression; + case BoundKind.DefaultLiteral: + var defaultExpression = (BoundDefaultLiteral)sourceExpression; if ((object)defaultExpression.Type == null) { return Conversion.DefaultLiteral; @@ -975,7 +975,7 @@ internal static bool HasImplicitConstantExpressionConversion(BoundExpression sou { var constantValue = source.ConstantValue; - if (constantValue == null || constantValue.IsDefaultLiteral) + if (constantValue == null || (object)source.Type == null) { return false; } diff --git a/src/Compilers/CSharp/Portable/BoundTree/BoundExpression.cs b/src/Compilers/CSharp/Portable/BoundTree/BoundExpression.cs index 8fd41a74eb37a..138bd51dd7edc 100644 --- a/src/Compilers/CSharp/Portable/BoundTree/BoundExpression.cs +++ b/src/Compilers/CSharp/Portable/BoundTree/BoundExpression.cs @@ -444,7 +444,7 @@ public override Symbol ExpressionSymbol } } - internal partial class BoundDefaultOperator + internal partial class BoundDefaultLiteral { public override ConstantValue ConstantValue { diff --git a/src/Compilers/CSharp/Portable/BoundTree/BoundExpressionExtensions.cs b/src/Compilers/CSharp/Portable/BoundTree/BoundExpressionExtensions.cs index d45de4dc1a445..506c18f927825 100644 --- a/src/Compilers/CSharp/Portable/BoundTree/BoundExpressionExtensions.cs +++ b/src/Compilers/CSharp/Portable/BoundTree/BoundExpressionExtensions.cs @@ -16,7 +16,7 @@ public static bool IsLiteralNull(this BoundExpression node) public static bool IsLiteralDefault(this BoundExpression node) { - return node.Kind == BoundKind.DefaultOperator && (object)node.Type == null; + return node.Kind == BoundKind.DefaultLiteral && (object)node.Type == null; } // returns true when expression has no side-effects and produces @@ -27,7 +27,7 @@ public static bool IsLiteralDefault(this BoundExpression node) // after some folding/propagation/algebraic transformations. public static bool IsDefaultValue(this BoundExpression node) { - if (node.Kind == BoundKind.DefaultOperator) + if (node.Kind == BoundKind.DefaultLiteral) { return true; } diff --git a/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml b/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml index 99e6375428808..4bde166f2628f 100644 --- a/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml +++ b/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml @@ -551,7 +551,7 @@ - + diff --git a/src/Compilers/CSharp/Portable/BoundTree/BoundTreeVisitors.cs b/src/Compilers/CSharp/Portable/BoundTree/BoundTreeVisitors.cs index f84414e9fb59e..03e52f0af7d24 100644 --- a/src/Compilers/CSharp/Portable/BoundTree/BoundTreeVisitors.cs +++ b/src/Compilers/CSharp/Portable/BoundTree/BoundTreeVisitors.cs @@ -48,8 +48,8 @@ public virtual R Visit(BoundNode node, A arg) return VisitArrayAccess(node as BoundArrayAccess, arg); case BoundKind.TypeOfOperator: return VisitTypeOfOperator(node as BoundTypeOfOperator, arg); - case BoundKind.DefaultOperator: - return VisitDefaultOperator(node as BoundDefaultOperator, arg); + case BoundKind.DefaultLiteral: + return VisitDefaultLiteral(node as BoundDefaultLiteral, arg); case BoundKind.IsOperator: return VisitIsOperator(node as BoundIsOperator, arg); case BoundKind.AsOperator: diff --git a/src/Compilers/CSharp/Portable/BoundTree/Constructors.cs b/src/Compilers/CSharp/Portable/BoundTree/Constructors.cs index 0294d2332147f..646dad071c250 100644 --- a/src/Compilers/CSharp/Portable/BoundTree/Constructors.cs +++ b/src/Compilers/CSharp/Portable/BoundTree/Constructors.cs @@ -523,14 +523,14 @@ public static BoundBlock SynthesizedNoLocals(SyntaxNode syntax, params BoundStat } } - internal partial class BoundDefaultOperator + internal partial class BoundDefaultLiteral { - public BoundDefaultOperator(SyntaxNode syntax, TypeSymbol type, bool hasErrors = false) + public BoundDefaultLiteral(SyntaxNode syntax, TypeSymbol type, bool hasErrors = false) : this(syntax, type.GetDefaultValue(), type, hasErrors) { } - public BoundDefaultOperator(SyntaxNode syntax) + public BoundDefaultLiteral(SyntaxNode syntax) : this(syntax, constantValueOpt: null, type: null, hasErrors: false) { } diff --git a/src/Compilers/CSharp/Portable/BoundTree/Expression.cs b/src/Compilers/CSharp/Portable/BoundTree/Expression.cs index 05a70d4ffe108..a70800cb0b27a 100644 --- a/src/Compilers/CSharp/Portable/BoundTree/Expression.cs +++ b/src/Compilers/CSharp/Portable/BoundTree/Expression.cs @@ -937,7 +937,7 @@ public override TResult Accept(OperationVisitor OperationKind.DefaultValueExpression; diff --git a/src/Compilers/CSharp/Portable/BoundTree/Formatting.cs b/src/Compilers/CSharp/Portable/BoundTree/Formatting.cs index d2028634f646c..f15b904b46630 100644 --- a/src/Compilers/CSharp/Portable/BoundTree/Formatting.cs +++ b/src/Compilers/CSharp/Portable/BoundTree/Formatting.cs @@ -120,7 +120,7 @@ public override object Display } } - internal partial class BoundDefaultOperator + internal partial class BoundDefaultLiteral { public override object Display { diff --git a/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs b/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs index 3dc7d31c60224..959506d32d4de 100644 --- a/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs +++ b/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs @@ -191,8 +191,8 @@ private void EmitExpressionCore(BoundExpression expression, bool used) EmitAsExpression((BoundAsOperator)expression, used); break; - case BoundKind.DefaultOperator: - EmitDefaultExpression((BoundDefaultOperator)expression, used); + case BoundKind.DefaultLiteral: + EmitDefaultExpression((BoundDefaultLiteral)expression, used); break; case BoundKind.TypeOfOperator: @@ -2617,7 +2617,7 @@ private void EmitDefaultValue(TypeSymbol type, bool used, SyntaxNode syntaxNode) } } - private void EmitDefaultExpression(BoundDefaultOperator expression, bool used) + private void EmitDefaultExpression(BoundDefaultLiteral expression, bool used) { Debug.Assert(expression.Type.SpecialType == SpecialType.System_Decimal || expression.Type.GetDefaultValue() == null, "constant should be set on this expression"); diff --git a/src/Compilers/CSharp/Portable/CodeGen/Optimizer.cs b/src/Compilers/CSharp/Portable/CodeGen/Optimizer.cs index df8df3a1017b3..57ec5b9ba15dc 100644 --- a/src/Compilers/CSharp/Portable/CodeGen/Optimizer.cs +++ b/src/Compilers/CSharp/Portable/CodeGen/Optimizer.cs @@ -1405,7 +1405,7 @@ public override BoundNode VisitUnaryOperator(BoundUnaryOperator node) if (node.OperatorKind.IsChecked() && node.OperatorKind.Operator() == UnaryOperatorKind.UnaryMinus) { var origStack = StackDepth(); - PushEvalStack(new BoundDefaultOperator(node.Syntax, node.Operand.Type), ExprContext.Value); + PushEvalStack(new BoundDefaultLiteral(node.Syntax, node.Operand.Type), ExprContext.Value); BoundExpression operand = (BoundExpression)this.Visit(node.Operand); return node.Update(node.OperatorKind, operand, node.ConstantValueOpt, node.MethodOpt, node.ResultKind, node.Type); } diff --git a/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs b/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs index 978e76795edbf..b37b6db512f5a 100644 --- a/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs +++ b/src/Compilers/CSharp/Portable/Compiler/MethodCompiler.cs @@ -1173,7 +1173,7 @@ private static BoundStatement ChainImplicitStructConstructor(MethodSymbol method new BoundAssignmentOperator( syntax, new BoundThisReference(syntax, containingType), - new BoundDefaultOperator(syntax, containingType), + new BoundDefaultLiteral(syntax, containingType), RefKind.None, containingType)); } diff --git a/src/Compilers/CSharp/Portable/FlowAnalysis/DataFlowPass.cs b/src/Compilers/CSharp/Portable/FlowAnalysis/DataFlowPass.cs index 184bad3c20ebd..aea6407bf9947 100644 --- a/src/Compilers/CSharp/Portable/FlowAnalysis/DataFlowPass.cs +++ b/src/Compilers/CSharp/Portable/FlowAnalysis/DataFlowPass.cs @@ -585,7 +585,7 @@ internal static bool WriteConsideredUse(TypeSymbol type, BoundExpression value) } return WriteConsideredUse(null, boundConversion.Operand); } - case BoundKind.DefaultOperator: + case BoundKind.DefaultLiteral: return false; case BoundKind.ObjectCreationExpression: var init = (BoundObjectCreationExpression)value; diff --git a/src/Compilers/CSharp/Portable/FlowAnalysis/FlowAnalysisPass.cs b/src/Compilers/CSharp/Portable/FlowAnalysis/FlowAnalysisPass.cs index f5855486af4ec..5b3a8a67bded9 100644 --- a/src/Compilers/CSharp/Portable/FlowAnalysis/FlowAnalysisPass.cs +++ b/src/Compilers/CSharp/Portable/FlowAnalysis/FlowAnalysisPass.cs @@ -56,7 +56,7 @@ public static BoundBlock Rewrite( { Debug.Assert(submissionResultType.SpecialType != SpecialType.System_Void); - var trailingExpression = new BoundDefaultOperator(method.GetNonNullSyntaxNode(), submissionResultType); + var trailingExpression = new BoundDefaultLiteral(method.GetNonNullSyntaxNode(), submissionResultType); var newStatements = block.Statements.Add(new BoundReturnStatement(trailingExpression.Syntax, RefKind.None, trailingExpression)); block = new BoundBlock(block.Syntax, ImmutableArray.Empty, newStatements) { WasCompilerGenerated = true }; #if DEBUG diff --git a/src/Compilers/CSharp/Portable/FlowAnalysis/PreciseAbstractFlowPass.cs b/src/Compilers/CSharp/Portable/FlowAnalysis/PreciseAbstractFlowPass.cs index 880b2b51b3ff3..f8fc4ed4d50da 100644 --- a/src/Compilers/CSharp/Portable/FlowAnalysis/PreciseAbstractFlowPass.cs +++ b/src/Compilers/CSharp/Portable/FlowAnalysis/PreciseAbstractFlowPass.cs @@ -2449,7 +2449,7 @@ public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement no return null; } - public override BoundNode VisitDefaultOperator(BoundDefaultOperator node) + public override BoundNode VisitDefaultLiteral(BoundDefaultLiteral node) { return null; } diff --git a/src/Compilers/CSharp/Portable/Lowering/Extensions.cs b/src/Compilers/CSharp/Portable/Lowering/Extensions.cs index 188a33818c2b2..00d6e932029b8 100644 --- a/src/Compilers/CSharp/Portable/Lowering/Extensions.cs +++ b/src/Compilers/CSharp/Portable/Lowering/Extensions.cs @@ -84,7 +84,7 @@ public static bool NullableNeverHasValue(this BoundExpression expr) } // "default(int?)" never has a value. - if (expr.Kind == BoundKind.DefaultOperator) + if (expr.Kind == BoundKind.DefaultLiteral) { return true; } diff --git a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/ExpressionLambdaRewriter.cs b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/ExpressionLambdaRewriter.cs index 995ab95aaf730..cdf83f4e4276c 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/ExpressionLambdaRewriter.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/ExpressionLambdaRewriter.cs @@ -231,7 +231,7 @@ private BoundExpression VisitExpressionWithoutStackGuard(BoundExpression node) case BoundKind.UnaryOperator: return VisitUnaryOperator((BoundUnaryOperator)node); - case BoundKind.DefaultOperator: + case BoundKind.DefaultLiteral: case BoundKind.HostObjectMemberReference: case BoundKind.Literal: case BoundKind.Local: diff --git a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.cs b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.cs index 522716c6ff368..3d632fd106120 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.cs @@ -535,7 +535,7 @@ private T IntroduceFrame(BoundNode node, LambdaFrame frame, Func.Empty, sideEffects: ImmutableArray.Create(sideEffect), - value: new BoundDefaultOperator(syntax, null, type), + value: new BoundDefaultLiteral(syntax, null, type), type: type); } @@ -1302,7 +1302,7 @@ private BoundExpression LowerLiftedBinaryArithmeticOperator( BoundExpression consequence = MakeLiftedBinaryOperatorConsequence(syntax, kind, callX_GetValueOrDefault, callY_GetValueOrDefault, type, method); // default(R?) - BoundExpression alternative = new BoundDefaultOperator(syntax, null, type); + BoundExpression alternative = new BoundDefaultLiteral(syntax, null, type); // tempX.HasValue & tempY.HasValue ? // new R?(tempX.GetValueOrDefault() OP tempY.GetValueOrDefault()) : @@ -1478,7 +1478,7 @@ private BoundExpression MakeNewNullableBoolean(SyntaxNode syntax, bool? value) NamedTypeSymbol nullableBoolType = nullableType.Construct(boolType); if (value == null) { - return new BoundDefaultOperator(syntax, null, nullableBoolType); + return new BoundDefaultLiteral(syntax, null, nullableBoolType); } return new BoundObjectCreationExpression( syntax, @@ -1520,7 +1520,7 @@ private BoundExpression OptimizeLiftedBooleanOperatorOneNull( BoundExpression alwaysNull = leftAlwaysNull ? left : right; BoundExpression notAlwaysNull = leftAlwaysNull ? right : left; BoundExpression neverNull = NullableAlwaysHasValue(notAlwaysNull); - BoundExpression nullBool = new BoundDefaultOperator(syntax, null, alwaysNull.Type); + BoundExpression nullBool = new BoundDefaultLiteral(syntax, null, alwaysNull.Type); if (neverNull != null) { diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs index 65d833375b4b7..fa2812189ab82 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs @@ -990,14 +990,14 @@ private BoundExpression GetDefaultParameterValue(SyntaxNode syntax, ParameterSym else { // The argument to M([Optional] int x) becomes default(int) - defaultValue = new BoundDefaultOperator(syntax, parameterType); + defaultValue = new BoundDefaultLiteral(syntax, parameterType); } } else if (defaultConstantValue.IsNull && parameterType.IsValueType) { // We have something like M(int? x = null) or M(S x = default(S)), // so replace the argument with default(int?). - defaultValue = new BoundDefaultOperator(syntax, parameterType); + defaultValue = new BoundDefaultLiteral(syntax, parameterType); } else if (parameterType.IsNullableType()) { @@ -1053,20 +1053,20 @@ private BoundExpression GetDefaultParameterSpecial(SyntaxNode syntax, ParameterS if (parameter.IsMarshalAsObject) { // default(object) - defaultValue = new BoundDefaultOperator(syntax, parameter.Type); + defaultValue = new BoundDefaultLiteral(syntax, parameter.Type); } else if (parameter.IsIUnknownConstant) { // new UnknownWrapper(default(object)) var methodSymbol = (MethodSymbol)_compilation.GetWellKnownTypeMember(WellKnownMember.System_Runtime_InteropServices_UnknownWrapper__ctor); - var argument = new BoundDefaultOperator(syntax, parameter.Type); + var argument = new BoundDefaultLiteral(syntax, parameter.Type); defaultValue = new BoundObjectCreationExpression(syntax, methodSymbol, argument); } else if (parameter.IsIDispatchConstant) { // new DispatchWrapper(default(object)) var methodSymbol = (MethodSymbol)_compilation.GetWellKnownTypeMember(WellKnownMember.System_Runtime_InteropServices_DispatchWrapper__ctor); - var argument = new BoundDefaultOperator(syntax, parameter.Type); + var argument = new BoundDefaultLiteral(syntax, parameter.Type); defaultValue = new BoundObjectCreationExpression(syntax, methodSymbol, argument); } else diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.cs index 5fdfa94ddd887..b95fff56e7831 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Conversion.cs @@ -175,7 +175,7 @@ private BoundExpression MakeConversionNode( if (NullableNeverHasValue(rewrittenOperand)) { - return new BoundDefaultOperator(syntax, rewrittenType); + return new BoundDefaultLiteral(syntax, rewrittenType); } BoundExpression nullableValue = NullableAlwaysHasValue(rewrittenOperand); @@ -191,7 +191,7 @@ private BoundExpression MakeConversionNode( case ConversionKind.DefaultLiteral: if (!_inExpressionLambda || !explicitCastInCode) { - return new BoundDefaultOperator(syntax, rewrittenType); + return new BoundDefaultLiteral(syntax, rewrittenType); } break; @@ -200,7 +200,7 @@ private BoundExpression MakeConversionNode( case ConversionKind.ExplicitReference: if (rewrittenOperand.IsDefaultValue() && (!_inExpressionLambda || !explicitCastInCode)) { - return new BoundDefaultOperator(syntax, rewrittenType); + return new BoundDefaultLiteral(syntax, rewrittenType); } break; @@ -218,7 +218,7 @@ private BoundExpression MakeConversionNode( case ConversionKind.ExplicitNumeric: if (rewrittenOperand.IsDefaultValue() && (!_inExpressionLambda || !explicitCastInCode)) { - return new BoundDefaultOperator(syntax, rewrittenType); + return new BoundDefaultLiteral(syntax, rewrittenType); } if (rewrittenType.SpecialType == SpecialType.System_Decimal || rewrittenOperand.Type.SpecialType == SpecialType.System_Decimal) @@ -271,7 +271,7 @@ private BoundExpression MakeConversionNode( rewrittenOperand.IsDefaultValue() && (!_inExpressionLambda || !explicitCastInCode)) { - return new BoundDefaultOperator(syntax, rewrittenType); + return new BoundDefaultLiteral(syntax, rewrittenType); } if (rewrittenType.SpecialType == SpecialType.System_Decimal) @@ -660,7 +660,7 @@ private static bool NullableNeverHasValue(BoundExpression expression) } // default(int?) never has a value. - if (expression.Kind == BoundKind.DefaultOperator) + if (expression.Kind == BoundKind.DefaultLiteral) { return true; } @@ -827,7 +827,7 @@ private BoundExpression RewriteFullyLiftedBuiltInConversion( conversion.UnderlyingConversions[0], type.GetNullableUnderlyingType(), @checked)); - BoundExpression alternative = new BoundDefaultOperator(syntax, null, type); + BoundExpression alternative = new BoundDefaultLiteral(syntax, null, type); BoundExpression conditionalExpression = RewriteConditionalOperator( syntax: syntax, rewrittenCondition: condition, @@ -855,7 +855,7 @@ private BoundExpression OptimizeLiftedUserDefinedConversion( if (NullableNeverHasValue(operand)) { - return new BoundDefaultOperator(syntax, type); + return new BoundDefaultLiteral(syntax, type); } // If the converted expression is known to never be null then we can return @@ -884,7 +884,7 @@ private BoundExpression OptimizeLiftedBuiltInConversion( if (NullableNeverHasValue(operand)) { - return new BoundDefaultOperator(syntax, null, type); + return new BoundDefaultLiteral(syntax, null, type); } // Second, a trickier optimization. If the conversion is "(T?)(new S?(x))" then @@ -1060,7 +1060,7 @@ private BoundExpression RewriteLiftedUserDefinedConversion( BoundExpression consequence = MakeLiftedUserDefinedConversionConsequence(userDefinedCall, rewrittenType); // default(R?) - BoundExpression alternative = new BoundDefaultOperator(syntax, rewrittenType); + BoundExpression alternative = new BoundDefaultLiteral(syntax, rewrittenType); // temp.HasValue ? new R?(op_Whatever(temp.GetValueOrDefault())) : default(R?) BoundExpression conditionalExpression = RewriteConditionalOperator( diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectCreationExpression.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectCreationExpression.cs index 8e15b32b82849..60a20a60eca65 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectCreationExpression.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_ObjectCreationExpression.cs @@ -63,7 +63,7 @@ public override BoundNode VisitObjectCreationExpression(BoundObjectCreationExpre // replace "new S()" with a default struct ctor with "default(S)" if (node.Constructor.IsDefaultValueTypeConstructor()) { - rewrittenObjectCreation = new BoundDefaultOperator(rewrittenObjectCreation.Syntax, rewrittenObjectCreation.Type); + rewrittenObjectCreation = new BoundDefaultLiteral(rewrittenObjectCreation.Syntax, rewrittenObjectCreation.Type); } if (!temps.IsDefaultOrEmpty) @@ -185,7 +185,7 @@ private BoundExpression MakeNewT(SyntaxNode syntax, TypeParameterSymbol typePara if (!this.TryGetWellKnownTypeMember(syntax, WellKnownMember.System_Activator__CreateInstance_T, out method)) { - return new BoundDefaultOperator(syntax, null, type: typeParameter, hasErrors: true); + return new BoundDefaultLiteral(syntax, null, type: typeParameter, hasErrors: true); } Debug.Assert((object)method != null); diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_UnaryOperator.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_UnaryOperator.cs index d477f11a0898a..4e9e4731394cb 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_UnaryOperator.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_UnaryOperator.cs @@ -199,7 +199,7 @@ private BoundExpression LowerLiftedUnaryOperator( BoundExpression consequence = GetLiftedUnaryOperatorConsequence(kind, syntax, method, type, call_GetValueOrDefault); // default(R?) - BoundExpression alternative = new BoundDefaultOperator(syntax, null, type); + BoundExpression alternative = new BoundDefaultLiteral(syntax, null, type); // temp.HasValue ? // new R?(OP(temp.GetValueOrDefault())) : @@ -233,7 +233,7 @@ private BoundExpression OptimizeLiftedUnaryOperator( { if (NullableNeverHasValue(loweredOperand)) { - return new BoundDefaultOperator(syntax, null, type); + return new BoundDefaultLiteral(syntax, null, type); } // Second, another simple optimization. If we know that the operand is never null @@ -636,7 +636,7 @@ private BoundExpression MakeUserDefinedIncrementOperator(BoundIncrementOperator BoundExpression consequence = new BoundObjectCreationExpression(syntax, ctor, userDefinedCall); // default(S?) - BoundExpression alternative = new BoundDefaultOperator(syntax, null, type); + BoundExpression alternative = new BoundDefaultLiteral(syntax, null, type); // temp.HasValue ? // new S?(op_Increment(temp.GetValueOrDefault())) : @@ -802,7 +802,7 @@ private BoundExpression MakeLiftedDecimalIncDecOperator(SyntaxNode syntax, Binar // new decimal?(op_Inc(x.GetValueOrDefault())) BoundExpression consequence = new BoundObjectCreationExpression(syntax, ctor, methodCall); // default(decimal?) - BoundExpression alternative = new BoundDefaultOperator(syntax, null, operand.Type); + BoundExpression alternative = new BoundDefaultLiteral(syntax, null, operand.Type); // x.HasValue ? new decimal?(op_Inc(x.GetValueOrDefault())) : default(decimal?) return RewriteConditionalOperator(syntax, condition, consequence, alternative, ConstantValue.NotAvailable, operand.Type); diff --git a/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/MethodToStateMachineRewriter.cs b/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/MethodToStateMachineRewriter.cs index 2983176a9268d..4d55fc9d48250 100644 --- a/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/MethodToStateMachineRewriter.cs +++ b/src/Compilers/CSharp/Portable/Lowering/StateMachineRewriter/MethodToStateMachineRewriter.cs @@ -522,7 +522,7 @@ private BoundExpression HoistExpression( case BoundKind.ThisReference: case BoundKind.BaseReference: - case BoundKind.DefaultOperator: + case BoundKind.DefaultLiteral: return expr; default: diff --git a/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs b/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs index deb1c20e8bd88..f8066265f15b6 100644 --- a/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs +++ b/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs @@ -1163,7 +1163,7 @@ public BoundExpression Array(TypeSymbol elementType, BoundExpression length) internal BoundExpression Default(TypeSymbol type) { - return new BoundDefaultOperator(Syntax, type) { WasCompilerGenerated = true }; + return new BoundDefaultLiteral(Syntax, type) { WasCompilerGenerated = true }; } internal BoundStatement Try( diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs b/src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs index 8cab368cc3423..dcfba6542d671 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs @@ -318,7 +318,7 @@ private static bool IsValidDefaultValue(BoundExpression expression) // Also when valuetype S has a parameterless constructor, // new S() is clearly not a constant expression and should produce an error return (expression.ConstantValue != null) || - (expression.Kind == BoundKind.DefaultOperator) || + (expression.Kind == BoundKind.DefaultLiteral) || (expression.Kind == BoundKind.ObjectCreationExpression && IsValidDefaultValue((BoundObjectCreationExpression)expression)); } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs index 64ed014f8504c..8400c72a1df50 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/UnsafeTests.cs @@ -1853,7 +1853,7 @@ S MakeS() No, ObjectCreationExpression 'new S()' is not a non-moveable variable No, Conversion 'default(S).i' is not a non-moveable variable No, FieldAccess 'default(S).i' is not a non-moveable variable -No, DefaultOperator 'default(S)' is not a non-moveable variable +No, DefaultLiteral 'default(S)' is not a non-moveable variable No, Conversion 'MakeS().i' is not a non-moveable variable No, FieldAccess 'MakeS().i' is not a non-moveable variable No, Call 'MakeS()' is not a non-moveable variable diff --git a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.cs b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.cs index 4b56c9d2e4d5b..808b4c53a586c 100644 --- a/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.cs +++ b/src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/LocalDeclarationRewriter.cs @@ -104,7 +104,7 @@ private static BoundExpression GetCustomTypeInfoPayloadId(SyntaxNode syntax, Met { if (!hasCustomTypeInfoPayload) { - return new BoundDefaultOperator(syntax, guidConstructor.ContainingType); + return new BoundDefaultLiteral(syntax, guidConstructor.ContainingType); } var value = ConstantValue.Create(DynamicFlagsCustomTypeInfo.PayloadTypeId.ToString());