Skip to content

C# Breaking change diagnosing constraint on static type as type arg in dynamic invocation #511

Closed

Description

@gafter

While fixing #345, I discovered that we had a breaking change. The following code passes the native compiler but fails to compile in Roslyn.

static class S {}
class C
{
    static unsafe void M()
    {
        dynamic d1 = 123;
        d1.N<S>(); // The dev11 compiler does not diagnose this
    }
    static void Main() {}
}

Although the language spec requires a diagnostic here, perhaps Roslyn should also let this pass.

Whichever we do, this should be documented in the compiler spec.

Activity

  1. added
    Tenet-Compatibility
    on Feb 14, 2015
  2. gafter commented on Feb 14, 2015

    @gafter
    MemberAuthor

    Hey compat council: @AnthonyDGreen @DustinCampbell @ljw1004 @MadsTorgersen @gafter @srivatsn @theoy

    We should decide what to do here. FYI I already have a fix prepared as the reversion to dev11 behavior is a natural consequence of my change for #345.

  3. added this to the 1.0-rc2 milestone on Feb 14, 2015
  4. changed the title [-]C# Breaking change diagnosing constraint on static type as type arg[/-] [+]C# Breaking change diagnosing constraint on static type as type arg in dynamic invocation[/+] on Feb 14, 2015
  5. self-assigned this
    on Feb 14, 2015
  6. added
    4 - In Review
    on Feb 14, 2015
  7. removed
    4 - In Review
    on Feb 18, 2015
  8. assigned and unassigned on Feb 18, 2015
  9. AlekseyTs commented on Feb 20, 2015

    @AlekseyTs
    Contributor

    @gafter, do you consider this issue addressed?

  10. gafter commented on Feb 20, 2015

    @gafter
    MemberAuthor

    I believe Roslyn is compatible with the native compiler in this area now due to checkin #513, that there is a test for this, and that this is also documented in the compiler spec section of the docs (https://github.com/dotnet/roslyn/blob/master/docs/compilers/CSharp/Static%20Type%20Constraints.md). I didn't realize the bug was not closed. I assigned this to you for verification, please.

  11. added
    4 - In Review
    and removed
    4 - In Review
    on Feb 22, 2015
  12. gafter commented on Feb 22, 2015

    @gafter
    MemberAuthor

    Closing, as this is fixed. Just needs verification.

  13. added
    4 - In Review
    and removed
    4 - In Review
    on Feb 22, 2015
  14. removed their assignment
    on Feb 27, 2015
  15. AlekseyTs commented on Feb 27, 2015

    @AlekseyTs
    Contributor

    Verified

  16. added a commit that references this issue on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompilersBugLanguage-C#Tenet-CompatibilityVerified

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions