void addLiftedOperators(TypeSymbol constrainedToTypeOpt, UnaryOperatorKind kind, ArrayBuilder <UnaryOperatorSignature> operators) { // SPEC: For the unary operators + ++ - -- ! ~ a lifted form of an operator exists // SPEC: if the operand and its result types are both non-nullable value types. // SPEC: The lifted form is constructed by adding a single ? modifier to the // SPEC: operator and result types. switch (kind) { case UnaryOperatorKind.UnaryPlus: case UnaryOperatorKind.PrefixDecrement: case UnaryOperatorKind.PrefixIncrement: case UnaryOperatorKind.UnaryMinus: case UnaryOperatorKind.PostfixDecrement: case UnaryOperatorKind.PostfixIncrement: case UnaryOperatorKind.LogicalNegation: case UnaryOperatorKind.BitwiseComplement: for (int i = operators.Count - 1; i >= 0; i--) { MethodSymbol op = operators[i].Method; TypeSymbol operandType = op.GetParameterType(0); TypeSymbol resultType = op.ReturnType; if (operandType.IsValidNullableTypeArgument() && resultType.IsValidNullableTypeArgument()) { operators.Add(new UnaryOperatorSignature( UnaryOperatorKind.Lifted | UnaryOperatorKind.UserDefined | kind, MakeNullable(operandType), MakeNullable(resultType), op, constrainedToTypeOpt)); } } break; } }