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

Regression: Explicit Implementation fails to compile #34583

Closed
YairHalberstadt opened this issue Mar 29, 2019 · 5 comments
Closed

Regression: Explicit Implementation fails to compile #34583

YairHalberstadt opened this issue Mar 29, 2019 · 5 comments
Labels
Area-Compilers Bug Feature - Nullable Reference Types Nullable Reference Types Tenet-Compatibility Violation of forwards/backwards compatibility in a design-time piece.
Milestone

Comments

@YairHalberstadt
Copy link
Contributor

YairHalberstadt commented Mar 29, 2019

Version Used:

master

Steps to Reproduce:

Compile the following code:

interface I
{
    void Foo<T, U>(T? value) where T : struct;
}

class C1 : I
{
    public void Foo<T, U>(T? value) where T : struct {}
}

class C2 : I
{
    void I.Foo<T, U>(T? value) {}
}

https://sharplab.io/#v2:EYLgZgpghgLgrgJwgZwLQDs4BstWFiVKABwEsAaGEUrAH1PRggTCgGMIACASQFgAoAN4DOozgAEALJwBiAezkAeACrlOAVQB8ACmUB+TgDcoWOBACUnAO4ALZl2WcQnZDARw2MANwCAvgIFxACZOAGEARiceAWF+MQkAZglpeSVVDR19IxMzS1t7TkdnV3dPTkF/fkrAkNCQ5z4hETEpHgA6VJU1LV0DY1MLcsrfIA==

Expected Behavior:

Everything compiles without error, as it does on VS 2017:

https://sharplab.io/#v2:C4LglgNgPmB2wFMBOAzAhgYwQAgJIFgAoAbyO3OwAEAWbAMQHsGAeAFQBpsBVAPgApWAfmwA3NBACuCAJTYA7gAtkOVthDYAzsCQSMwANxEAvkSKUATNgDCARjV4ipQhSoBmKrUYsO3fkNHiUrKKytiq6lo6etjEJoRxZpZWluoEJGQUNHgAdF5snLwCwmKSMjFxRkA=

Actual Behavior:

error CS8627: A nullable type parameter must be known to be a value type or non-nullable reference type. Consider adding a 'class', 'struct', or type constraint.
error CS0539: 'C2.Foo<T, U>(T?)' in explicit interface declaration is not a member of interface
error CS0535: 'C2' does not implement interface member 'I.Foo<T, U>(T?)'

@YairHalberstadt YairHalberstadt changed the title Explict Implementation fails to compile Regression: Explicit Implementation fails to compile Mar 29, 2019
@gafter gafter added Bug Area-Compilers Tenet-Compatibility Violation of forwards/backwards compatibility in a design-time piece. Feature - Nullable Reference Types Nullable Reference Types labels Mar 30, 2019
@gafter
Copy link
Member

gafter commented Mar 31, 2019

As a workaround you can write Nullable<T> in the explicit implementation.

@gafter
Copy link
Member

gafter commented Mar 31, 2019

The following three issues appear to be related: #31676 #34508 #34583

@YairHalberstadt
Copy link
Contributor Author

I will take a look at this as a part of #34584

@YairHalberstadt
Copy link
Contributor Author

#34584 appears to have fixed it.

@YairHalberstadt
Copy link
Contributor Author

#34584 appears to have fixed it.

Actually not (at the time i wrote that comment), but I've fixed it now in that PR.

See #34584 (comment)

@jcouv jcouv modified the milestones: 16.1, 16.1.P3 Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Feature - Nullable Reference Types Nullable Reference Types Tenet-Compatibility Violation of forwards/backwards compatibility in a design-time piece.
Projects
None yet
Development

No branches or pull requests

3 participants