You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Fact]
public void Test()
{
var source = @"
class Outer : Base
{
void M1(Base? x1, Base y1)
{
if (x1 == null) return;
Outer y = x1;
x1.ToString();
y = (Outer)x1;
y = y1;
}
}
class Base {}
";
CreateCompilation(source, options: WithNonNullTypesTrue()).VerifyDiagnostics(
// (7,19): error CS0266: Cannot implicitly convert type 'Base' to 'Outer'. An explicit conversion exists (are you missing a cast?)
// Outer y = x1;
Diagnostic(ErrorCode.ERR_NoImplicitConvCast, "x1").WithArguments("Base", "Outer").WithLocation(7, 19),
// (7,19): warning CS8619: Nullability of reference types in value of type 'Base' doesn't match target type 'Outer'.
// Outer y = x1;
Diagnostic(ErrorCode.WRN_NullabilityMismatchInAssignment, "x1").WithArguments("Base", "Outer").WithLocation(7, 19),
// (10,13): error CS0266: Cannot implicitly convert type 'Base' to 'Outer'. An explicit conversion exists (are you missing a cast?)
// y = y1;
Diagnostic(ErrorCode.ERR_NoImplicitConvCast, "y1").WithArguments("Base", "Outer").WithLocation(10, 13),
// (10,13): warning CS8619: Nullability of reference types in value of type 'Base' doesn't match target type 'Outer'.
// y = y1;
Diagnostic(ErrorCode.WRN_NullabilityMismatchInAssignment, "y1").WithArguments("Base", "Outer").WithLocation(10, 13)
);
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: