Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postconditions on user-defined conversion parameters are not respected #49575

Closed
RikkiGibson opened this issue Nov 23, 2020 · 0 comments · Fixed by #59169
Closed

Postconditions on user-defined conversion parameters are not respected #49575

RikkiGibson opened this issue Nov 23, 2020 · 0 comments · Fixed by #59169

Comments

@RikkiGibson
Copy link
Contributor

Version Used: dc6f316

Steps to Reproduce:

#nullable enable

using System.Diagnostics.CodeAnalysis;

public static class Program
{
    public static void M1(string? s)
    {
        AssertNotNull(s);
        s.ToString();
    }

    public static void M2(string? s)
    {
        C c = s;
        s.ToString(); // 1
    }

    public static void AssertNotNull([AllowNull, NotNull] string s) { throw null!; }

    public class C
    {
        public static implicit operator C([AllowNull, NotNull] string s) { throw null!; }
    }
}

SharpLab

Expected Behavior: No diagnostics

Actual Behavior: Diagnostic indicated by // 1.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 23, 2020
@jaredpar jaredpar added Feature - Nullable Reference Types Nullable Reference Types Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 1, 2020
@jaredpar jaredpar added this to the 16.9 milestone Dec 1, 2020
@jaredpar jaredpar modified the milestones: 16.9, Compiler.Next Apr 26, 2021
@RikkiGibson RikkiGibson self-assigned this Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants