Skip to content

Commit

Permalink
Remove unused method
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Nov 12, 2020
1 parent df60b06 commit 37c5d73
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5329,11 +5329,11 @@ private void VisitArgumentConversionAndInboundAssignmentsAndPreConditions(
// 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 = result.RValueType.Type;
Debug.Assert(argumentResultType is not null);
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);
}
}
Expand Down Expand Up @@ -6402,17 +6402,6 @@ private void TrackNullableStateOfNullableValue(int containingSlot, TypeSymbol co
}
}

private void TrackNullableStateOfNullableValue(BoundExpression node, BoundExpression operand, TypeSymbol convertedType, TypeWithAnnotations underlyingType)
{
int valueSlot = MakeSlot(operand);
if (valueSlot > 0)
{
int containingSlot = GetOrCreatePlaceholderSlot(node);
Debug.Assert(containingSlot > 0);
TrackNullableStateOfNullableValue(containingSlot, convertedType, operand, underlyingType.ToTypeWithState(), valueSlot);
}
}

private void TrackNullableStateOfTupleConversion(
BoundConversion? conversionOpt,
BoundExpression convertedNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60830,6 +60830,60 @@ static void Main(object? x)
);
}

[Fact]
public void ImplicitConversion_Typeless()
{
var source = @"
public struct Optional<T>
{
public static implicit operator Optional<T>(T value) => throw null!;
}

class C
{
static void G1(Optional<object> a) => throw null!;
static void G2(Optional<object?> a) => throw null!;

static void M()
{
G1(null); // 1
G2(null);
}
}";
var comp = CreateCompilation(source, options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (14,12): warning CS8625: Cannot convert null literal to non-nullable reference type.
// G1(null); // 1
Diagnostic(ErrorCode.WRN_NullAsNonNullable, "null").WithLocation(14, 12)
);
}

[Fact]
public void ImplicitConversion_Typeless_WithConstraint()
{
var source = @"
public struct Optional<T> where T : class
{
public static implicit operator Optional<T>(T value) => throw null!;
}

class C
{
static void G(Optional<object> a) => throw null!;

static void M()
{
G(null);
}
}";
var comp = CreateCompilation(source, options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (13,11): warning CS8625: Cannot convert null literal to non-nullable reference type.
// G(null);
Diagnostic(ErrorCode.WRN_NullAsNonNullable, "null").WithLocation(13, 11)
);
}

[Fact, WorkItem(41763, "https://github.com/dotnet/roslyn/issues/41763")]
public void Conversions_EnumToUnderlyingType_SemanticModel()
{
Expand Down

0 comments on commit 37c5d73

Please sign in to comment.