Skip to content
Merged
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
24 changes: 17 additions & 7 deletions src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6624,14 +6624,24 @@ private bool HasTopLevelNullabilityConversion(TypeWithAnnotations source, TypeWi
}

/// <summary>
/// Apply the conversion to the type of the operand and return the resulting type. (If the
/// operand does not have an explicit type, the operand expression is used for the type.)
/// If `checkConversion` is set, the incoming conversion is assumed to be from binding and will be
/// re-calculated, this time considering nullability. (Note that the conversion calculation considers
/// nested nullability only. The caller is responsible for checking the top-level nullability of
/// the type returned by this method.) `trackMembers` should be set if the nullability of any
/// members of the operand should be copied to the converted result when possible.
/// Apply the conversion to the type of the operand and return the resulting type.
/// If the operand does not have an explicit type, the operand expression is used.
/// </summary>
/// <param name="checkConversion">
/// If <see langword="true"/>, the incoming conversion is assumed to be from binding
/// and will be re-calculated, this time considering nullability.
/// Note that the conversion calculation considers nested nullability only.
/// The caller is responsible for checking the top-level nullability of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may I ask what do you mean by top-level nullablity? is it the outermost/initial/current state?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion from List<string?> to List<string> has a nested nullability violation, while the conversion from List<string>? to List<string>, has a top-level nullability violation.

/// the type returned by this method.
/// </param>
/// <param name="trackMembers">
/// If <see langword="true"/>, the nullability of any members of the operand
/// will be copied to the converted result when possible.
/// </param>
/// <param name="useLegacyWarnings">
/// If <see langword="true"/>, indicates that the "non-safety" diagnostic <see cref="ErrorCode.WRN_ConvertingNullableToNonNullable"/>
/// should be given for an invalid conversion.
/// </param>
private TypeWithState VisitConversion(
BoundConversion? conversionOpt,
BoundExpression conversionOperand,
Expand Down