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

Enable a default implementation of an interface property/indexer to be provided as part of its declaration. #18110

Conversation

AlekseyTs
Copy link
Contributor

@dotnet/roslyn-compiler Please review.

Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

{
// PROTOTYPE(DefaultInterfaceImplementation): Should we check language version as well?
// Usually, it is done based on specific syntax that targets a new feature, but in this case
// no special syntax is used. Also, partial types can have declarations coming from different
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use CSharpCompilation.LanguageVersion. Partial types cannot have declarations coming from different trees with different language versions. The compiler checks up front that all input trees have the same language version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still there is no special syntax at this site.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree that there is no special syntax at this site. But there is a new language feature being used. In any case I agree with your decision to document it as an open issue with a PROTOTYPE comment.

@@ -755,7 +781,8 @@ private DeclarationModifiers MakeModifiers(SyntaxTokenList modifiers, bool isExp
// Proper errors must have been reported by now.
if (isInterface)
{
mods = (mods & ~DeclarationModifiers.AccessibilityMask) | DeclarationModifiers.Abstract | DeclarationModifiers.Public;
mods = (mods & ~DeclarationModifiers.AccessibilityMask) | DeclarationModifiers.Public |
(accessorsHaveImplementation ? DeclarationModifiers.Virtual : DeclarationModifiers.Abstract);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct if one accessor is abstract and one virtual?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see that is left as a future work item.

@AlekseyTs
Copy link
Contributor Author

@dotnet/roslyn-compiler Please review, need a second sign-off.

@jcouv
Copy link
Member

jcouv commented Mar 23, 2017

    private void PropertyImplementation_101(string source1)

Consider naming helper methods with "Assert" or "Verify" to distinguish them from tests.


Refers to: src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs:1250 in 59a8ffa. [](commit_id = 59a8ffa, deletion_comment = False)

@jcouv
Copy link
Member

jcouv commented Mar 23, 2017

    private void PropertyImplementation_101(string source1)

I see that you used "Validate" below. That works.


In reply to: 288867427 [](ancestors = 288867427)


Refers to: src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs:1250 in 59a8ffa. [](commit_id = 59a8ffa, deletion_comment = False)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AlekseyTs
Copy link
Contributor Author

Thanks! I'll address feedback in the next PR.

@AlekseyTs AlekseyTs merged commit deba3ea into dotnet:features/DefaultInterfaceImplementation Mar 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants